This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] combine (and (or x, c1), c2) => (and x, c2) iff c1 & c2 == 0
ClosedPublic

Authored by jroelofs on Oct 14 2021, 5:05 PM.

Diff Detail

Event Timeline

jroelofs created this revision.Oct 14 2021, 5:05 PM
jroelofs requested review of this revision.Oct 14 2021, 5:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 5:05 PM
jroelofs edited the summary of this revision. (Show Details)Oct 14 2021, 5:13 PM
paquette added inline comments.Oct 15 2021, 9:54 AM
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
4030

Could you just replace the operands of the existing G_AND rather than building a new G_AND?

llvm/test/CodeGen/AArch64/GlobalISel/combine-and-or-disjoint-mask.mir
6

maybe a vector testcase too?

jroelofs updated this revision to Diff 380086.Oct 15 2021, 12:57 PM

Modify the G_AND in-place, and ignore vector types.

jroelofs marked 2 inline comments as done.Oct 15 2021, 12:57 PM
paquette accepted this revision.Oct 20 2021, 10:55 AM

LGTM

(Maybe add a comment explaining why you're ignoring vectors here though.)

This revision is now accepted and ready to land.Oct 20 2021, 10:55 AM
foad added a subscriber: foad.Oct 22 2021, 7:29 AM

This is another case that would ideally be handled with demanded bits analysis. We would visit (or x, c1), see that none of the bits set in c1 are demanded, and simplify to x.