]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Clobber the condition code in the bfin doloop patterns
authorJeff Law <jeffreyalaw@gmail.com>
Sat, 20 Nov 2021 16:20:07 +0000 (11:20 -0500)
committerJeff Law <jeffreyalaw@gmail.com>
Sat, 20 Nov 2021 16:30:09 +0000 (11:30 -0500)
Per Aldy's excellent, but tough to follow analysis in PR 103226, this patch
fixes the bfin-elf regression.

In simplest terms the doloop patterns on this port may clobber the condition
code register, but they do not expose that until after register allocation.
That would be fine, except that other patterns have exposed CC earlier.  As
a result the dataflow, particularly for CC, is incorrect.

This leads the register allocators to assume that a value in CC outside the
loop is still valid inside the loop when in fact, the value has been
clobbered.  This is what caused pr80974 to start failing.

With this fix, not only do we fix the pr80974 regression, but we fix ~20
other execution failures in the port.  It also reduces test time for the
port from ~90 minutes to ~60 minutes.

PR tree-optimization/103226
gcc/
* config/bfin/bfin.md (doloop pattern, splitter and expander): Clobber
CC.

gcc/config/bfin/bfin.md

index fd65f4d9e63199c989f4722811a4aac97dacfc09..10a19aac23e83929e4207ca5799d0499dda4430a 100644 (file)
                   (plus:SI (match_dup 0)
                            (const_int -1)))
              (unspec [(const_int 0)] UNSPEC_LSETUP_END)
-             (clobber (match_dup 2))])] ; match_scratch
+             (clobber (match_dup 2))
+             (clobber (reg:BI REG_CC))])] ; match_scratch
   ""
 {
   /* The loop optimizer doesn't check the predicates... */
        (plus (match_dup 2)
              (const_int -1)))
    (unspec [(const_int 0)] UNSPEC_LSETUP_END)
-   (clobber (match_scratch:SI 3 "=X,&r,&r"))]
+   (clobber (match_scratch:SI 3 "=X,&r,&r"))
+   (clobber (reg:BI REG_CC))]
   ""
   "@
    /* loop end %0 %l1 */
        (plus (match_dup 0)
              (const_int -1)))
    (unspec [(const_int 0)] UNSPEC_LSETUP_END)
-   (clobber (match_scratch:SI 2))]
+   (clobber (match_scratch:SI 2))
+   (clobber (reg:BI REG_CC))]
   "memory_operand (operands[0], SImode) || splitting_loops"
   [(set (match_dup 2) (match_dup 0))
    (set (match_dup 2) (plus:SI (match_dup 2) (const_int -1)))