]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR rtl-optimization/61673 (Miscompilation of _gnutls_hostname_compare on s390)
authorJakub Jelinek <jakub@redhat.com>
Tue, 8 Jul 2014 15:39:36 +0000 (17:39 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 8 Jul 2014 15:39:36 +0000 (17:39 +0200)
PR rtl-optimization/61673
* combine.c (simplify_comparison): Test just mode's sign bit
in tmode rather than the sign bit and any bits above it.

* gcc.c-torture/execute/pr61673.c: New test.

From-SVN: r212364

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr61673.c [new file with mode: 0644]

index b5ad7bd5a0659e6137c3df57208cf4d4f1c5a059..19506531bd6ac6166163bac24b71d4a787259ecb 100644 (file)
@@ -1,3 +1,9 @@
+2014-07-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/61673
+       * combine.c (simplify_comparison): Test just mode's sign bit
+       in tmode rather than the sign bit and any bits above it.
+
 2014-07-08  Roman Gareev  <gareevroman@gmail.com>
 
        * graphite-isl-ast-to-gimple.c (generate_isl_context):
index 4e7ef55126e42638c63f5ffab92bad68d93edb55..08f5638972491a621b82c11540b1877aca18ced0 100644 (file)
@@ -11981,7 +11981,7 @@ simplify_comparison (enum rtx_code code, rtx *pop0, rtx *pop1)
                = (unsigned HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (mode) - 1);
              op0 = simplify_gen_binary (AND, tmode,
                                         gen_lowpart (tmode, op0),
-                                        gen_int_mode (sign, mode));
+                                        gen_int_mode (sign, tmode));
              code = (code == LT) ? NE : EQ;
              break;
            }
index 765eb9f41f3aaaf4538d411af61b11fe23646e07..83015edd995a28bc6cfcdaca0071146dccbfac63 100644 (file)
@@ -1,5 +1,8 @@
 2014-07-08  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/61673
+       * gcc.c-torture/execute/pr61673.c: New test.
+
        PR tree-optimization/61725
        * gcc.dg/tree-ssa/vrp93.c: New test.
        * gcc.c-torture/execute/pr61725.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr61673.c b/gcc/testsuite/gcc.c-torture/execute/pr61673.c
new file mode 100644 (file)
index 0000000..b3e243d
--- /dev/null
@@ -0,0 +1,50 @@
+/* PR rtl-optimization/61673 */
+
+char e;
+
+__attribute__((noinline, noclone)) void
+bar (char x)
+{
+  if (x != 0x54 && x != (char) 0x87)
+    __builtin_abort ();
+}
+
+__attribute__((noinline, noclone)) void
+foo (const char *x)
+{
+  char d = x[0];
+  int c = d;
+  if ((c >= 0 && c <= 0x7f) == 0)
+    e = d;
+  bar (d);
+}
+
+__attribute__((noinline, noclone)) void
+baz (const char *x)
+{
+  char d = x[0];
+  int c = d;
+  if ((c >= 0 && c <= 0x7f) == 0)
+    e = d;
+}
+
+int
+main ()
+{
+  const char c[] = { 0x54, 0x87 };
+  e = 0x21;
+  foo (c);
+  if (e != 0x21)
+    __builtin_abort ();
+  foo (c + 1);
+  if (e != (char) 0x87)
+    __builtin_abort ();
+  e = 0x21;
+  baz (c);
+  if (e != 0x21)
+    __builtin_abort ();
+  baz (c + 1);
+  if (e != (char) 0x87)
+    __builtin_abort ();
+  return 0;
+}