https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67089

--- Comment #3 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Mike from comment #2)
> (In reply to Uroš Bizjak from comment #1)
> > We shouldn't do this, and it reflected in PR58779.
> But can't we improve the logic to satisfy both pr58779 and pr67089? The
> absolute metric is code quality, and with all due respect, the code can be
> better in this very case.

I don't see a way. pr58779 will generate:

(set (pc)
    (if_then_else (gtu (plus:SI (reg:SI 86 [ D.1769 ])
                (const_int -1 [0xffffffffffffffff]))
            (reg:SI 86 [ D.1769 ]))
        (label_ref 22)
        (pc)))

which can be also represented as:

(set (pc)
    (if_then_else (gtu (minus:SI (reg:SI 86 [ D.1769 ])
                (const_int 1 [0x1]))
            (reg:SI 86 [ D.1769 ]))
        (label_ref 22)
        (pc)))

and before pr58779 was fixed, these two equivalent insns would result in
swapped condition, as evident from the diff:

     case GTU:                  /* CF=0 & ZF=0 */
     case LEU:                  /* CF=1 | ZF=1 */
-      /* Detect overflow checks.  They need just the carry flag.  */
-      if (GET_CODE (op0) == MINUS
-         && rtx_equal_p (op1, XEXP (op0, 0)))
-       return CCCmode;
-      else
-       return CCmode;
+      return CCmode;

and the part where GTU is emitted:

@@ -14103,8 +14103,6 @@
         Those same assemblers have the same but opposite lossage on cmov.  */
       if (mode == CCmode)
        suffix = fp ? "nbe" : "a";
-      else if (mode == CCCmode)
-       suffix = "b";
       else
        gcc_unreachable ();
       break;

Reply via email to