This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAGBuilder][WIP] Teach visitBr to sink AND along with compares.
Changes PlannedPublic

Authored by craig.topper on Nov 18 2022, 7:35 PM.

Details

Summary

visitBr expands i1 And/Or of compares into multiple branches and
basic blocks.

We should also sink any Ands on the compare input if it would allow
the target to use an instruction like x86's TEST.

Need to cleanup some comments and add more tests. But wanted to
get early feedback on the direction.

Another option might be to use CodeGenPrepare to do the expansion.
I think it already does for fast isel. CodeGenPrepare already has
code for sinking Ands to compares.

Diff Detail

Event Timeline

craig.topper created this revision.Nov 18 2022, 7:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2022, 7:35 PM
craig.topper requested review of this revision.Nov 18 2022, 7:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2022, 7:35 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm accepted this revision.Dec 5 2022, 11:49 AM

LGTM with nit

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
2219–2220

also use match for the zero case?

This revision is now accepted and ready to land.Dec 5 2022, 11:49 AM
craig.topper planned changes to this revision.May 1 2023, 12:06 PM