]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/33992 (Miscompiles function with inlining, breaks profiledboo...
authorUros Bizjak <ubizjak@gmail.com>
Mon, 11 Feb 2008 08:27:00 +0000 (09:27 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 11 Feb 2008 08:27:00 +0000 (08:27 +0000)
2008-02-11  Uros Bizjak  <ubizjak@gmail.com>
Richard Guenther  <rguenther@suse.de>

PR tree-optimization/33992
* tree-ssa-loop-im.c (rewrite_bittest): Fixup the type of
the zero we compare against.

* gcc.c-torture/execute/pr33992.c: New testcase.

Co-Authored-By: Richard Guenther <rguenther@suse.de>
From-SVN: r132234

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr33992.c [new file with mode: 0644]
gcc/tree-ssa-loop-im.c

index c41e364cfe747b06ba79a9bf931c1ecd1c46ad4e..a5fa886892eb2608c34b0fa861d77a0278f025f7 100644 (file)
@@ -1,3 +1,10 @@
+2008-02-11  Uros Bizjak  <ubizjak@gmail.com>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/33992
+       * tree-ssa-loop-im.c (rewrite_bittest): Fixup the type of
+       the zero we compare against.
+
 2008-02-09  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        PR middle_end/34150
index 505fa85b154a72edf2e9568dabf7084d3d404a56..6919390d8dd77771a2e8627e3aec6729803f9dd4 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-11  Uros Bizjak  <ubizjak@gmail.com>
+       Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/33992
+       * gcc.c-torture/execute/pr33992.c: New testcase.
+
 2008-02-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
        * gfortran.dg/streamio_14.f90:  New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr33992.c b/gcc/testsuite/gcc.c-torture/execute/pr33992.c
new file mode 100644 (file)
index 0000000..c574596
--- /dev/null
@@ -0,0 +1,38 @@
+extern void abort ();
+
+void __attribute__((noinline))
+bar (unsigned long long i)
+{
+  if (i)
+    abort ();
+}
+
+void __attribute__((always_inline))
+foo (unsigned long long *r)
+
+{
+  int i;
+
+  for (i = 0; ; i++)
+    if (*r & ((unsigned long long)1 << (63 - i)))
+      break;
+
+  bar (i);
+}
+
+void __attribute__((noinline))
+do_test (unsigned long long *r)
+{
+  int i;
+
+  for (i = 0; i < 2; ++i)
+    foo (r);
+}
+
+int main()
+{
+  unsigned long long r = 0x8000000000000001ull;
+
+  do_test (&r);
+  return 0;
+}
index 262ad972da8bcf26fe33694a303c48058496c4fb..cad14452a16ac17f1f6e333a273342039ec1eee6 100644 (file)
@@ -685,7 +685,12 @@ rewrite_bittest (block_stmt_iterator *bsi)
       stmt2 = build_gimple_modify_stmt (var, t);
       name = make_ssa_name (var, stmt2);
       GIMPLE_STMT_OPERAND (stmt2, 0) = name;
+
+      /* Replace the SSA_NAME we compare against zero.  Adjust
+        the type of zero accordingly.  */
       SET_USE (use, name);
+      TREE_OPERAND (COND_EXPR_COND (use_stmt), 1)
+       = build_int_cst_type (TREE_TYPE (name), 0);
 
       bsi_insert_before (bsi, stmt1, BSI_SAME_STMT);
       bsi_replace (bsi, stmt2, true);