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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-05-24
             Status|UNCONFIRMED                 |NEW

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #0)
>
> void __GIMPLE(ssa, startwith("optimized"))
> foo (long *p, long a, long b, long c, long d, long e, long f)
> {
>   _Bool _2;
>   long _3;
>   long _8;
> 
>   __BB(2):
>       _2 = a_1(D) < b_10(D);
>       _3 = _2 ? c_4(D) : d_5(D);
>       _8 = _2 ? f_6(D) : e_7(D);
>       __MEM <long> (p_9(D)) = _3;
>       __MEM <long> (p_9(D) + 4) = _8;
>       return;
> }
> 
> #if __GNUC__ < 13
> void __GIMPLE(ssa, startwith("optimized"))
> bar (long *p, long a, long b, long c, long d, long e, long f)
> {
>   long _3;
>   long _8;
> 
>   __BB(2):
>       _3 = a_1(D) < b_10(D) ? c_4(D) : d_5(D);
>       _8 = a_1(D) >= b_10(D) ? e_7(D) : f_6(D);
>       __MEM <long> (p_9(D)) = _3;
>       __MEM <long> (p_9(D) + 4) = _8;
>       return;
> }
> #endif

So with the above we do have (on the GCC 12 branch)

foo:
.LFB0:
        .cfi_startproc
        cmpq    %rdx, %rsi
        setl    %al
        testb   %al, %al
        cmovne  8(%rsp), %r9
        cmove   %r8, %rcx
        movq    %rcx, (%rdi)
        movq    %r9, 4(%rdi)
        ret

vs.

bar:
.LFB1:
        .cfi_startproc
        cmpq    %rdx, %rsi
        cmovl   8(%rsp), %r9
        cmovge  %r8, %rcx
        movq    %rcx, (%rdi)
        movq    %r9, 4(%rdi)
        ret

which shows an optimization difference when the condition is split out.
It also shows the condition is split out anyway in the end, it's just
the RTL representation with CCnn modes doesn't nicely match up the
GIMPLE so we somehow need to improve the plumbing here.  But CCnn
get clobbered quite a lot and so any clever "CSE"ing of the (different!)
modes involved is going to require code motion or CCnn spilling (bad).

Reply via email to