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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |15.0
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Andrew Pinski from comment #5)
> > Created attachment 57993 [details]
> > Patch but it does not work for the code in this testcase
> > 
> > I have to look into why it is not working for the testcase in comment #0
> > (factor_out_conditional_operation is not even called) but it does work for:
> > ```
> > short f(int a, short b, short c)
> > {
> >   if (a)
> >     return __builtin_bswap16(b);
> >   return __builtin_bswap16(c);
> > }
> > ```
> 
> This patch was committed as r15-2986-gcd2f394418be0c.

A few other patches which was done in GCC 15 which fixes this now.

The loop in GCC 15 now gives:
```
.L9:
        ldrd    r3, r2, [r4]
        cmp     r2, r3
        it      lt
        ldrblt  r0, [r4, #8]        @ zero_extendqisi2
        blt     .L8
        bl      i
        uxth    r0, r0
.L8:
        ldr     r3, [r5, r0, lsl #2]
        str     r0, [r4, #12]
        blx     r3
        ldr     r0, [r4, #16]
        cmp     r0, #0
        bne     .L9
```

For x86_64 it is:
```
.L15:
        movsbw  g(%rip), %ax
.L10:
        movzwl  %ax, %eax
        movl    %eax, l(%rip)
        call    *a(,%rax,8)
        movl    e(%rip), %eax
        testl   %eax, %eax
        je      .L14
.L11:
        movl    h(%rip), %eax
        cmpl    %eax, d(%rip)
        jl      .L15
        call    i
        jmp     .L10
```

Reply via email to