]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/29797 (Miscompiles bit test / set in OpenOffice)
authorRoger Sayle <sayle@gcc.gnu.org>
Mon, 13 Nov 2006 00:41:53 +0000 (00:41 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Mon, 13 Nov 2006 00:41:53 +0000 (00:41 +0000)
2006-11-12  Michael Matz  <matz@suse.de>
    Roger Sayle  <roger@eyesopen.com>

PR rtl-optimization/29797
* ifcvt.c (noce_try_bitop): Correct calculation of bitnum on
BITS_BIG_ENDIAN targets.

* gcc.c-torture/execute/pr29797-1.c: New test case.

From-SVN: r118740

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr29797-1.c [new file with mode: 0644]

index 0eacd1e7b8bccea99c8412996c4c94f67727fb5c..bf326de9eea956846ed734d8d6ad4d94a623a817 100644 (file)
@@ -1,3 +1,10 @@
+2006-11-12  Michael Matz  <matz@suse.de>
+           Roger Sayle  <roger@eyesopen.com>
+
+       PR rtl-optimization/29797
+       * ifcvt.c (noce_try_bitop): Correct calculation of bitnum on
+       BITS_BIG_ENDIAN targets.
+
 2006-11-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * builtins.c (fold_builtin_cosh): New.
index 4d7341cec887e0b24f44e2d575a339143150c95d..f2226c402aabe398c6f011f80c225a90c367a6f2 100644 (file)
@@ -1943,7 +1943,9 @@ noce_try_bitop (struct noce_if_info *if_info)
        return FALSE;
       bitnum = INTVAL (XEXP (cond, 2));
       mode = GET_MODE (x);
-      if (bitnum >= HOST_BITS_PER_WIDE_INT)
+      if (BITS_BIG_ENDIAN)
+       bitnum = GET_MODE_BITSIZE (mode) - 1 - bitnum;
+      if (bitnum < 0 || bitnum >= HOST_BITS_PER_WIDE_INT)
        return FALSE;
     }
   else
index 7237d4f2b7d566935e052442cc2ada007c4ef78f..4566f8855b437c729afe405e568d52b70735e874 100644 (file)
@@ -1,3 +1,8 @@
+2006-11-12  Roger Sayle  <roger@eyesopen.com>
+
+       PR rtl-optimization/29797
+       * gcc.c-torture/execute/pr29797-1.c: New test case.
+
 2006-11-12  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.dg/torture/builtin-symmetric-1.c: Add more cases.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr29797-1.c b/gcc/testsuite/gcc.c-torture/execute/pr29797-1.c
new file mode 100644 (file)
index 0000000..9bcc2a9
--- /dev/null
@@ -0,0 +1,14 @@
+extern void abort(void);
+
+unsigned int bar(void) { return 32768; }
+
+int main()
+{
+  unsigned int nStyle = bar ();
+  if (nStyle & 32768)
+    nStyle |= 65536;
+  if (nStyle != (32768 | 65536))
+    abort ();
+  return 0;
+}
+