]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/69399 (wrong code with -O and int128)
authorJakub Jelinek <jakub@redhat.com>
Wed, 27 Jan 2016 11:40:04 +0000 (12:40 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 27 Jan 2016 11:40:04 +0000 (12:40 +0100)
PR tree-optimization/69399
* wide-int.h (wi::lrshift): For larger precisions, only
use fast path if shift is known to be < HOST_BITS_PER_WIDE_INT.

* gcc.dg/torture/pr69399.c: New test.

From-SVN: r232869

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr69399.c [new file with mode: 0644]
gcc/wide-int.h

index a66eee53098e7303e9acbca95bd24114990298a7..12a2583610d5ad5a10eda885ecda71d67bcab01f 100644 (file)
@@ -1,3 +1,9 @@
+2016-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/69399
+       * wide-int.h (wi::lrshift): For larger precisions, only
+       use fast path if shift is known to be < HOST_BITS_PER_WIDE_INT.
+
 2016-01-27  Claudiu Zissulescu  <claziss@synopsys.com>
 
         * config/arc/predicates.md (proper_comparison_operator): Reject
index b7e6dac4ba985d7f652a0401d2cb142e9ae724ed..aa3d51bbe456d1fe9d6a8f2e7bc0d75e1f1005f5 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/69399
+       * gcc.dg/torture/pr69399.c: New test.
+
 2016-01-27  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/tree-ssa/ssa-dom-cse-2.c: XFAIL on SPARC 64-bit.
diff --git a/gcc/testsuite/gcc.dg/torture/pr69399.c b/gcc/testsuite/gcc.dg/torture/pr69399.c
new file mode 100644 (file)
index 0000000..24fa48c
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do run { target int128 } } */
+
+static unsigned __attribute__((noinline, noclone))
+foo (unsigned long long u)
+{
+  unsigned __int128 v = u | 0xffffff81U;
+  v >>= 64;
+  return v;
+}
+
+int
+main ()
+{
+  unsigned x = foo (27);
+  if (x != 0)
+    __builtin_abort ();
+  return 0;
+}
index 56cf5827a0d769a3604c60eba32a87b3f2bfff31..fa133f0561ad04cb584d3b219ab28a115985118f 100644 (file)
@@ -2909,7 +2909,9 @@ wi::lrshift (const T1 &x, const T2 &y)
         For variable-precision integers like wide_int, handle HWI
         and sub-HWI integers inline.  */
       if (STATIC_CONSTANT_P (xi.precision > HOST_BITS_PER_WIDE_INT)
-         ? xi.len == 1 && xi.val[0] >= 0
+         ? (shift < HOST_BITS_PER_WIDE_INT
+            && xi.len == 1
+            && xi.val[0] >= 0)
          : xi.precision <= HOST_BITS_PER_WIDE_INT)
        {
          val[0] = xi.to_uhwi () >> shift;