summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-03-05 22:13:58 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-03-05 22:13:58 +0000
commit36ec77582591940a4605548156b11122b3fd76e0 (patch)
treec7c2c5cdf293033049f224f00c35f10f0d73b21d
parentc751e2cd4cc2e15f626c8c9ee6cfeb7fcf48410f (diff)
downloadgcc-36ec77582591940a4605548156b11122b3fd76e0.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258263 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/combine.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/powerpc/pr84700.c12
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5630a84a949..716e77abc99 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+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-05 Segher Boessenkool <segher@kernel.crashing.org>
* config/rs6000/rs6000.c (rs6000_loop_align): Don't align tiny loops
diff --git a/gcc/combine.c b/gcc/combine.c
index ddea5b18fe0..a4efd11703c 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5734,7 +5734,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);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9f9afb0df12..ca2986b6221 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2018-03-05 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/84700
+ * gcc.target/powerpc/pr84700.c: New test.
+
2018-03-05 Nathan Sidwell <nathan@acm.org>
PR c++/84702
diff --git a/gcc/testsuite/gcc.target/powerpc/pr84700.c b/gcc/testsuite/gcc.target/powerpc/pr84700.c
new file mode 100644
index 00000000000..c89094a56d3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr84700.c
@@ -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);
+}