]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/35833 (Wrong code generated with -ftree-vrp)
authorRichard Guenther <rguenther@suse.de>
Tue, 8 Apr 2008 22:07:20 +0000 (22:07 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 8 Apr 2008 22:07:20 +0000 (22:07 +0000)
2008-04-05  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/35833
* tree-vrp.c (operand_less_p): Deal with non-INTEGER_CST
results from fold_binary_to_constant.
(compare_values_warnv): Likewise.

* gcc.dg/torture/pr35833.c: New testcase.

From-SVN: r134111

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20080408-1.c [new file with mode: 0644]

index 9fdf703d4f7f815ac064052f3f571b655fdc5d34..36e7853b765b8485f483e9e84d5b3d58cce36845 100644 (file)
@@ -1,3 +1,8 @@
+2008-04-08  Richard Guenther  <rguenther@suse.de>
+
+       * fold-const.c (fold_widened_comparison): Do not allow
+       sign-changes that change the result.
+
 2008-04-03  Bob Wilson  <bob.wilson@acm.org>
 
        * config/xtensa/xtensa.c (xtensa_secondary_reload_class): Use a
index 23523debf41fea038dc1f86e9f63b074284f1622..dde8f88720a06262d8c4682e3884b06338457583 100644 (file)
@@ -6663,7 +6663,11 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1)
        || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type))
       && (TREE_TYPE (arg1_unw) == shorter_type
          || (TYPE_PRECISION (shorter_type)
-             >= TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+             > TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+         || ((TYPE_PRECISION (shorter_type)
+              == TYPE_PRECISION (TREE_TYPE (arg1_unw)))
+             && (TYPE_UNSIGNED (shorter_type)
+                 == TYPE_UNSIGNED (TREE_TYPE (arg1_unw))))
          || (TREE_CODE (arg1_unw) == INTEGER_CST
              && (TREE_CODE (shorter_type) == INTEGER_TYPE
                  || TREE_CODE (shorter_type) == BOOLEAN_TYPE)
index 8c8f5840357b67a1c8f7f11a2c4ed519c9cda720..ad991a5b532d3d86430d755725a591de95eb7548 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-08  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.c-torture/execute/20080408-1.c: New testcase.
+
 2008-04-01  Laurent GUERBY  <laurent@guerby.net>
 
        * ada/acats/norun.lst: Add c9a011b.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20080408-1.c b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c
new file mode 100644 (file)
index 0000000..9e1ff63
--- /dev/null
@@ -0,0 +1,11 @@
+extern void abort (void);
+int main ()
+{
+  short ssi = 126;
+  unsigned short usi = 65280;
+  int fail = !(ssi < usi);
+  if (fail)
+    abort ();
+  return 0;
+}
+