]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/84700 (ICE on 32-bit BE powerpc targets w/ -misel -O1)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:27:47 +0000 (19:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:27:47 +0000 (19:27 +0200)
Backported from mainline
2018-03-05  Jakub Jelinek  <jakub@redhat.com>

PR target/84700
* combine.c (combine_simplify_rtx): Don't try to simplify if
if_then_else_cond returned non-NULL, but either true_rtx or false_rtx
are equal to x.

* gcc.target/powerpc/pr84700.c: New test.

From-SVN: r262070

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr84700.c [new file with mode: 0644]

index 350caf5d93821494acf65a1c03ee16e9c7eed758..05359d44f500c8552ac3fb3769582af8a083dae6 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/84700
+       * combine.c (combine_simplify_rtx): Don't try to simplify if
+       if_then_else_cond returned non-NULL, but either true_rtx or false_rtx
+       are equal to x.
+
        2018-03-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR inline-asm/84625
index c38b57dd38e2a86277c7dbe3788363fc710dd3db..8ffb21dc10a8072f73330979fed34e53fd84c53e 100644 (file)
@@ -5581,7 +5581,11 @@ combine_simplify_rtx (rtx x, machine_mode op0_mode, int in_dest,
          /* If everything is a comparison, what we have is highly unlikely
             to be simpler, so don't use it.  */
          && ! (COMPARISON_P (x)
-               && (COMPARISON_P (true_rtx) || COMPARISON_P (false_rtx))))
+               && (COMPARISON_P (true_rtx) || COMPARISON_P (false_rtx)))
+         /* Similarly, if we end up with one of the expressions the same
+            as the original, it is certainly not simpler.  */
+         && ! rtx_equal_p (x, true_rtx)
+         && ! rtx_equal_p (x, false_rtx))
        {
          rtx cop1 = const0_rtx;
          enum rtx_code cond_code = simplify_comparison (NE, &cond, &cop1);
index 22893b53d0fae97e92d1a72e8a4ac3ed546742b9..9da363f67f171df35f08aa88427c4f73fe5eccf2 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/84700
+       * gcc.target/powerpc/pr84700.c: New test.
+
        2018-03-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/84662
diff --git a/gcc/testsuite/gcc.target/powerpc/pr84700.c b/gcc/testsuite/gcc.target/powerpc/pr84700.c
new file mode 100644 (file)
index 0000000..c89094a
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR target/84700 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -misel" } */
+
+long long int
+foo (long long int x)
+{
+  long long int a = x < 2;
+  int b = a >= 0;
+
+  return a + ((x == 0) ? a : b);
+}