Patch to zap const_int hex values in md files.

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Tue Nov 13 15:03:00 GMT 2001


While investigating something else, I noticed that gcc had const_ints
in some md files that were given hex values.  It turns out that
read-rtl.c passes the string representation of the value to
ato{i,l,ll} which when confronted with 0x... always yields 0.  Since
these are "build" files we don't have libiberty's strtol (or strtoll
for that matter) so we can't DTRT WRT bases other than 10.  See:
http://gcc.gnu.org/ml/gcc/2001-11/msg00853.html

Below is a patch to correct this.  I tested it by cross compiling to
1750a-unknown-elf and i386-unknown-linux-gnu, the only insn-*.[ch]
differences are as one would expect and are shown here:

--- orig/build-1750a-unknown-elf/gcc/insn-recog.c	Mon Nov 19 08:42:14 2001
+++ build-1750a-unknown-elf/gcc/insn-recog.c	Mon Nov 19 08:40:32 2001
@@ -1510,7 +1510,7 @@ recog_1 (x0, insn, pnum_clobbers)
  L265: ATTRIBUTE_UNUSED_LABEL
   x3 = XEXP (x2, 0);
   if (GET_CODE (x3) == CONST_INT
-      && XWINT (x3, 0) == 0)
+      && XWINT (x3, 0) == 32768)
     goto L266;
   x1 = XEXP (x0, 0);
   goto L112;
@@ -2272,7 +2272,7 @@ recog_1 (x0, insn, pnum_clobbers)
  L273: ATTRIBUTE_UNUSED_LABEL
   x4 = XEXP (x3, 0);
   if (GET_CODE (x4) == CONST_INT
-      && XWINT (x4, 0) == 0)
+      && XWINT (x4, 0) == 32768)
     goto L274;
   goto L113;
 
--- orig/build-i386-unknown-linux-gnu/gcc/insn-emit.c	Mon Nov 19 08:42:14 2001
+++ build-i386-unknown-linux-gnu/gcc/insn-emit.c	Mon Nov 19 08:41:01 2001
@@ -5222,10 +5222,10 @@ gen_pmulhrwv4hi3 (operand0, operand1, op
 	gen_rtx_VEC_CONST (V4SImode,
 	gen_rtx_PARALLEL (VOIDmode,
 	gen_rtvec (4,
-		const0_rtx,
-		const0_rtx,
-		const0_rtx,
-		const0_rtx)))),
+		GEN_INT (32768),
+		GEN_INT (32768),
+		GEN_INT (32768),
+		GEN_INT (32768))))),
 	GEN_INT (16))));
 }
 
--- orig/build-i386-unknown-linux-gnu/gcc/insn-recog.c	Mon Nov 19 08:41:48 2001
+++ build-i386-unknown-linux-gnu/gcc/insn-recog.c	Mon Nov 19 08:41:01 2001
@@ -21657,28 +21657,28 @@ recog_16 (x0, insn, pnum_clobbers)
  L8912: ATTRIBUTE_UNUSED_LABEL
   x6 = XVECEXP (x5, 0, 0);
   if (GET_CODE (x6) == CONST_INT
-      && XWINT (x6, 0) == 0)
+      && XWINT (x6, 0) == 32768)
     goto L8913;
   goto ret0;
 
  L8913: ATTRIBUTE_UNUSED_LABEL
   x6 = XVECEXP (x5, 0, 1);
   if (GET_CODE (x6) == CONST_INT
-      && XWINT (x6, 0) == 0)
+      && XWINT (x6, 0) == 32768)
     goto L8914;
   goto ret0;
 
  L8914: ATTRIBUTE_UNUSED_LABEL
   x6 = XVECEXP (x5, 0, 2);
   if (GET_CODE (x6) == CONST_INT
-      && XWINT (x6, 0) == 0)
+      && XWINT (x6, 0) == 32768)
     goto L8915;
   goto ret0;
 
  L8915: ATTRIBUTE_UNUSED_LABEL
   x6 = XVECEXP (x5, 0, 3);
   if (GET_CODE (x6) == CONST_INT
-      && XWINT (x6, 0) == 0)
+      && XWINT (x6, 0) == 32768)
     goto L8916;
   goto ret0;
 


Here's the patch, ok to install?

		Thanks,
		--Kaveh


2001-11-19  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* 1750a.md: Don't use hex format for a const_int.
	* i386.md: Likewise.

diff -rup orig/egcs-CVS20011118/gcc/config/1750a/1750a.md egcs-CVS20011118/gcc/config/1750a/1750a.md
--- orig/egcs-CVS20011118/gcc/config/1750a/1750a.md	Fri Oct 19 15:33:30 2001
+++ egcs-CVS20011118/gcc/config/1750a/1750a.md	Mon Nov 19 07:46:29 2001
@@ -809,7 +809,7 @@
 (define_insn ""
   [(set (match_operand:QI 0 "register_operand" "=r")
         (ior:QI  (match_operand:QI 1 "register_operand" "0")
-                 (lshiftrt:QI (const_int 0x8000)
+                 (lshiftrt:QI (const_int 32768)
                       (match_operand:QI 2 "register_operand" "r"))))]
   ""
   "svbr   r%2,%r0")
@@ -818,7 +818,7 @@
 (define_insn ""
   [(set (match_operand:QI 0 "general_operand" "=r")
         (and:QI  (match_operand:QI 1 "general_operand" "0")
-            (not:QI (lshiftrt:QI (const_int 0x8000)
+            (not:QI (lshiftrt:QI (const_int 32768)
                         (match_operand:QI 2 "register_operand" "r")))))]
   ""
   "rvbr   r%2,%r0")
diff -rup orig/egcs-CVS20011118/gcc/config/i386/i386.md egcs-CVS20011118/gcc/config/i386/i386.md
--- orig/egcs-CVS20011118/gcc/config/i386/i386.md	Fri Nov 16 16:30:33 2001
+++ egcs-CVS20011118/gcc/config/i386/i386.md	Mon Nov 19 07:46:10 2001
@@ -19676,10 +19676,10 @@
 	            (sign_extend:V4SI
 		       (match_operand:V4HI 2 "nonimmediate_operand" "ym")))
 	      (vec_const:V4SI
-	         (parallel [(const_int 0x8000)
-			    (const_int 0x8000)
-			    (const_int 0x8000)
-			    (const_int 0x8000)])))
+	         (parallel [(const_int 32768)
+			    (const_int 32768)
+			    (const_int 32768)
+			    (const_int 32768)])))
 	   (const_int 16))))]
   "TARGET_3DNOW"
   "pmulhrw\\t{%2, %0|%0, %2}"



More information about the Gcc-patches mailing list