re PR tree-optimization/47155 (ccp caused miscompilation)
authorJakub Jelinek <jakub@redhat.com>
Mon, 3 Jan 2011 21:01:14 +0000 (22:01 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 3 Jan 2011 21:01:14 +0000 (22:01 +0100)
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.

From-SVN: r168440

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr47155.c [new file with mode: 0644]
gcc/tree-ssa-ccp.c

index 62bd11e655a3cb88e59e8e9e76b8639de10bd2b9..20e8a8e8633ae34f3029ccb8d277e0e5e1d70b62 100644 (file)
@@ -1,5 +1,9 @@
 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.
+
        PR rtl-optimization/47157
        * combine.c (try_combine): If undobuf.other_insn becomes
        (set (pc) (pc)) jump, call update_cfg_for_uncondjump on it
index 910fa08c98c9ae76b9f5201fe6238a05387f7db2..40223f88b0f4a22c24d7af011aa79b93769fa859 100644 (file)
@@ -1,5 +1,8 @@
 2011-01-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/47155
+       * gcc.c-torture/execute/pr47155.c: New test.
+
        PR rtl-optimization/47157
        * gcc.c-torture/compile/pr47157.c: New test.
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr47155.c b/gcc/testsuite/gcc.c-torture/execute/pr47155.c
new file mode 100644 (file)
index 0000000..6210a2f
--- /dev/null
@@ -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;
+}
index 29aa55c7ba249a3c149a28afe4befaafffaafedf..b2494d72476ddb7a90be0f472f3e61521b2e10b6 100644 (file)
@@ -1764,8 +1764,8 @@ bit_value_binop_1 (enum tree_code code, tree type,
                   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;