This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Turn a wider range of select of constants into math
Needs ReviewPublic

Authored by deadalnix on Jul 29 2022, 5:35 AM.

Details

Reviewers
laytonio
RKSimon
spatel
gchatelet
lei
nemanjai
steven.zhang
Group Reviewers
Restricted Project
Summary
select Cond, 0, C2 --> (zext(not Cond) << log2(C2)) if C2 is a power of 2.
select Cond, C1, C2 --> (zext(Cond) << log2(C1 - C2)) + C2 if C1 -C2 is a power of 2.

This addresses some regressions in D130675 . It is a bit of a mixed bag for PowerPC .

Diff Detail

Event Timeline

deadalnix created this revision.Jul 29 2022, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 5:35 AM
deadalnix requested review of this revision.Jul 29 2022, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 5:35 AM
deadalnix updated this revision to Diff 448634.Jul 29 2022, 8:01 AM

Avoid complex combines when we expect to fold into select_cc

deadalnix added inline comments.Jul 29 2022, 8:19 AM
llvm/test/CodeGen/X86/select.ll
995 ↗(On Diff #448634)

Is this good or bad? @RKSimon , @gchatelet ?

deadalnix updated this revision to Diff 448654.Jul 29 2022, 9:06 AM

Fix CodeGen/PowerPC/nofpexcept.ll

Ressurect select Cond, Pow2, 0 --> (zext Cond) << log2(Pow2)

deadalnix edited the summary of this revision. (Show Details)Jul 29 2022, 9:07 AM
RKSimon added inline comments.Aug 2 2022, 5:25 AM
llvm/test/CodeGen/X86/select.ll
995 ↗(On Diff #448634)

Probably worse - 3op LEA isn't great on some cpus

deadalnix added inline comments.Aug 5 2022, 7:47 AM
llvm/test/CodeGen/X86/select.ll
995 ↗(On Diff #448654)

D131260 will help to lean on that pattern more consistently.

Overall not great for PPC, but not problematic enough for me to stand in the way if this provides improvements on other targets.

Is this still necessary?

chfast added a subscriber: chfast.Nov 5 2022, 11:38 AM
deadalnix updated this revision to Diff 473452.Nov 5 2022, 12:43 PM

Rebase and cleanup