+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
/* 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);
--- /dev/null
+/* 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);
+}