This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

i386 insn-output.c warnings fixes


While I was mucking with output templates I fixed a few warnings in
the generated insn-output.c:

- "control reaches end of non-void function": missing an abort for the
  impossible cases of a switch.

- "integer overflow in expression": (1 << 31) overflows 32-bit signed
  int.  ((1 << 31) - 1) correctly evaluates to 2147483647, but only by
  virtue of the representation of signed int being 32-bit
  twos-complement, which is not guaranteed.

  Replaced those by (((unsigned int) 1) << 31) - 1, which _is_
  required to evaluate to 2147483647, as long as UINT_MAX is at least
  2147483648 (minimum maximum here is 65535, but we're screwed anyway
  if we try to build GCC with a compiler with 16-bit int...)  
  1U cannot be used, since it is not available in K+R C.

I'm bootstrapping this alongside the current set of md-syntax-sugar patches.

zw

	* i386.md (*truncdfsf2_2): Abort if which_alternative is not 0 or 1.
	(*adddi_1_rex64, *adddi_2_rex64, *adddi_3_rex64,
	*adddi_4_rex64, *adddi_5_rex64): Cast 1 to unsigned int.

===================================================================
Index: config/i386/i386.md
--- config/i386/i386.md	2001/06/26 10:47:33	1.280
+++ config/i386/i386.md	2001/06/26 23:39:15
@@ -4367,6 +4367,8 @@
 	return \"fstp%z0\\t%y0\";
       else
 	return \"fst%z0\\t%y0\";
+    default:
+      abort ();
     }
 }"
   [(set_attr "type" "sse,fmov")
@@ -5616,7 +5618,7 @@
 	 Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
       if (GET_CODE (operands[2]) == CONST_INT
 	  /* Avoid overflows.  */
-	  && ((INTVAL (operands[2]) & ((1 << 31) - 1)))
+	  && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
           && (INTVAL (operands[2]) == 128
 	      || (INTVAL (operands[2]) < 0
 		  && INTVAL (operands[2]) != -128)))
@@ -5689,7 +5691,7 @@
 	 Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
       if (GET_CODE (operands[2]) == CONST_INT
 	  /* Avoid overflows.  */
-	  && ((INTVAL (operands[2]) & ((1 << 31) - 1)))
+	  && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
           && (INTVAL (operands[2]) == 128
 	      || (INTVAL (operands[2]) < 0
 		  && INTVAL (operands[2]) != -128)))
@@ -5740,7 +5742,7 @@
 	 Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
       if (GET_CODE (operands[2]) == CONST_INT
 	  /* Avoid overflows.  */
-	  && ((INTVAL (operands[2]) & ((1 << 31) - 1)))
+	  && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
           && (INTVAL (operands[2]) == 128
 	      || (INTVAL (operands[2]) < 0
 		  && INTVAL (operands[2]) != -128)))
@@ -5793,7 +5795,7 @@
 	   || (INTVAL (operands[2]) > 0
 	       && INTVAL (operands[2]) != 128))
 	  /* Avoid overflows.  */
-	  && ((INTVAL (operands[2]) & ((1 << 31) - 1))))
+	  && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1))))
 	return \"sub{q}\\t{%2, %0|%0, %2}\";
       operands[2] = GEN_INT (-INTVAL (operands[2]));
       return \"add{q}\\t{%2, %0|%0, %2}\";
@@ -5839,7 +5841,7 @@
 	 Exceptions: -128 encodes smaller than 128, so swap sign and op.  */
       if (GET_CODE (operands[2]) == CONST_INT
 	  /* Avoid overflows.  */
-	  && ((INTVAL (operands[2]) & ((1 << 31) - 1)))
+	  && ((INTVAL (operands[2]) & ((((unsigned int) 1) << 31) - 1)))
           && (INTVAL (operands[2]) == 128
 	      || (INTVAL (operands[2]) < 0
 		  && INTVAL (operands[2]) != -128)))


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]