There already was code to just use the original reg:CC, but it was
positioned incorrectly: if the original code (that this RTL is
simplified from) did not already start with a COMPARE (or not in
the right mode), it didn't trigger.  But it is valid in that case
as well.

This then allows merging the other two arms of this conditional;
do so.

Bootstrapped and regression tested on powerpc64-linux and x86_64-linux;
no regressions.  Also built toolchains and Linux kernels for every
arch where that works; no new failures on that.

Any objections?


Segher


2015-05-11  Segher Boessenkool  <seg...@kernel.crashing.org>

        * combine.c (simplify_set): When generating a CC set, if the
        source already is in the correct mode, do not wrap it in a
        compare.  Simplify the rest of that code.

---
 gcc/combine.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/gcc/combine.c b/gcc/combine.c
index 896d9d2..51f78a5 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6675,20 +6675,16 @@ simplify_set (rtx x)
       if (other_changed)
        undobuf.other_insn = other_insn;
 
-      /* Otherwise, if we didn't previously have a COMPARE in the
-        correct mode, we need one.  */
-      if (GET_CODE (src) != COMPARE || GET_MODE (src) != compare_mode)
-       {
-         SUBST (SET_SRC (x), gen_rtx_COMPARE (compare_mode, op0, op1));
-         src = SET_SRC (x);
-       }
-      else if (GET_MODE (op0) == compare_mode && op1 == const0_rtx)
+      /* Don't generate a compare of a CC with 0, just use that CC.  */
+      if (GET_MODE (op0) == compare_mode && op1 == const0_rtx)
        {
          SUBST (SET_SRC (x), op0);
          src = SET_SRC (x);
        }
-      /* Otherwise, update the COMPARE if needed.  */
-      else if (XEXP (src, 0) != op0 || XEXP (src, 1) != op1)
+      /* Otherwise, if we didn't previously have the same COMPARE we
+        want, create it from scratch.  */
+      else if (GET_CODE (src) != COMPARE || GET_MODE (src) != compare_mode
+              || XEXP (src, 0) != op0 || XEXP (src, 1) != op1)
        {
          SUBST (SET_SRC (x), gen_rtx_COMPARE (compare_mode, op0, op1));
          src = SET_SRC (x);
-- 
1.8.1.4

Reply via email to