[PATCH v2] ifcvt: Avoid early multiple-set conversion for extend patterns
Jeffrey Law
jeffrey.law@oss.qualcomm.com
Sat Jan 17 16:29:26 GMT 2026
On 1/15/2026 1:55 PM, Jeffrey Law wrote:
>
>> (subreg:SI (ior:DI (reg/v:DI 135 [ a ])
>> (reg/v:DI 136 [ b ])) 0)
>
> Unfortunately num_sign_bit_copies for those objects is not returning
> anything useful in this context.
>
> I want to think about this a bit more. It really feels like we should
> have a better solution than special casing this in ifcvt.
So after a bit of pondering, I think we have a clean way forward. I've
cc'd Daniel as it's an area he's done some recent work.
In the .optimized dump we have:
> if (c_2(D) != 0)
> goto <bb 3>; [50.00%]
> else
> goto <bb 4>; [50.00%]
> ;; succ: 3 [50.0% (guessed)] count:536870912 (estimated
> locally, freq 0.5000) (TRUE_VALUE,EXECUTABLE)
> ;; 4 [50.0% (guessed)] count:536870912 (estimated
> locally, freq 0.5000) (FALSE_VALUE,EXECUTABLE)
>
> ;; basic block 3, loop depth 0, count 536870912 (estimated locally,
> freq 0.5000), maybe hot
> ;; prev block 2, next block 4, flags: (NEW, REACHABLE, VISITED)
> ;; pred: 2 [50.0% (guessed)] count:536870912 (estimated
> locally, freq 0.5000) (TRUE_VALUE,EXECUTABLE)
> a_5 = a_3(D) | b_4(D);
> ;; succ: 4 [always] count:536870912 (estimated locally, freq
> 0.5000) (FALLTHRU,EXECUTABLE)
>
> ;; basic block 4, loop depth 0, count 1073741824 (estimated locally,
> freq 1.0000), maybe hot
> ;; prev block 3, next block 1, flags: (NEW, REACHABLE, VISITED)
> ;; pred: 2 [50.0% (guessed)] count:536870912 (estimated
> locally, freq 0.5000) (FALSE_VALUE,EXECUTABLE)
> ;; 3 [always] count:536870912 (estimated locally, freq
> 0.5000) (FALLTHRU,EXECUTABLE)
> # a_1 = PHI <a_3(D)(2), a_5(3)>
That seems like another case we can likely handle with Andrew's new
infrastructure to drive phi-opt from match.pd and turn that mess into a
branchless sequence in gimple.
Jeff
More information about the Gcc-patches
mailing list