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]
Other format: [Raw text]

[PATCH] Fix ccp bit_value_binop_1 (PR tree-optimization/47155)


Hi!

My recent tree-ssa-ccp.c change broke the following testcase.
It is correct that the type used is the lhs type, but uns
needs to be taken from r1type instead of type, at least for the comparisons.
For non-comparisons I believe it ought to be the same as type (or uselessly
convertible to it) and most of the callers pass the exactly same type
to that function for both type and r1type anyway.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2011-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/47155
	* tree-ssa-ccp.c (bit_value_binop_1): Use r1type instead of type
	when computing uns.

	* gcc.c-torture/execute/pr47155.c: New test.

--- gcc/tree-ssa-ccp.c.jj	2011-01-03 09:54:28.000000000 +0100
+++ gcc/tree-ssa-ccp.c	2011-01-03 10:19:06.000000000 +0100
@@ -1764,8 +1764,8 @@ bit_value_binop_1 (enum tree_code code, 
 		   tree r1type, double_int r1val, double_int r1mask,
 		   tree r2type, double_int r2val, double_int r2mask)
 {
-  bool uns = (TREE_CODE (type) == INTEGER_TYPE
-	      && TYPE_IS_SIZETYPE (type) ? 0 : TYPE_UNSIGNED (type));
+  bool uns = (TREE_CODE (r1type) == INTEGER_TYPE
+	      && TYPE_IS_SIZETYPE (r1type) ? 0 : TYPE_UNSIGNED (r1type));
   /* Assume we'll get a constant result.  Use an initial varying value,
      we fall back to varying in the end if necessary.  */
   *mask = double_int_minus_one;
--- gcc/testsuite/gcc.c-torture/execute/pr47155.c.jj	2011-01-03 10:27:55.000000000 +0100
+++ gcc/testsuite/gcc.c-torture/execute/pr47155.c	2011-01-03 10:27:38.000000000 +0100
@@ -0,0 +1,14 @@
+/* PR tree-optimization/47155 */
+
+unsigned int a;
+static signed char b = -127;
+int c = 1;
+
+int
+main (void)
+{
+  a = b <= (unsigned char) (-6 * c);
+  if (!a)
+    __builtin_abort ();
+  return 0;
+}

	Jakub


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