]> 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>
Fri, 22 Jun 2018 20:29:34 +0000 (22:29 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 20:29:34 +0000 (22:29 +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: r261913

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

index 25a5ae403fe7cf43d251fa95d7f75e7c2001a076..7e1744f500f4367cd8e4eb018c66257523cdfac9 100644 (file)
@@ -1,14 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
-       2018-03-02  Jakub Jelinek  <jakub@redhat.com>
+       2018-03-05  Jakub Jelinek  <jakub@redhat.com>
 
-       PR c++/84662
-       * pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
-       RETURN instead of return.
-       <case POINTER_PLUS_EXPR>: Likewise.
-       <case CONVERT_EXPR>: If op0 is error_mark_node, just return
-       it instead of wrapping it into CONVERT_EXPR.
+       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-06-22  Andre Vieira  <andre.simoesdiasvieira@arm.com>
 
index 064e4f97d01df356ad33c484e89478ebe4b62ba7..d1133c3ce5246ee0090cb0091239dc20c3df7855 100644 (file)
@@ -5637,7 +5637,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 2d06819d4555c0981df1cd34af638c94a097aa81..5df7e4235251ab2e9baf3c55c1328d854492ed44 100644 (file)
@@ -1,3 +1,15 @@
+2018-06-22  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2018-03-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/84662
+       * pt.c (tsubst_copy_and_build) <case TEMPLATE_ID_EXPR>: Use
+       RETURN instead of return.
+       <case POINTER_PLUS_EXPR>: Likewise.
+       <case CONVERT_EXPR>: If op0 is error_mark_node, just return
+       it instead of wrapping it into CONVERT_EXPR.
+
 2018-06-12  Jason Merrill  <jason@redhat.com>
 
        PR c++/85815 - reference to member of enclosing template.
index c018e18a3c74b8fdb1a84a0c58cb7c1c294be52d..cc106e7fb55bc4e41be83fb66a45806d57975d81 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-22  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);
+}