This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Support folding and/or/xor with a constant vector RHS into selects and phis
ClosedPublic

Authored by craig.topper on Apr 3 2017, 11:16 AM.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 3 2017, 11:16 AM
spatel edited edge metadata.Apr 3 2017, 1:16 PM

Can you add or change the bitwise logic tests to not have splat constants? That should allow us to expose the difference in a regression test (SimplifyDemanded doesn't handle non-splat afaik).
Also, for the bitwise logic tests, please add tests with a phi op, so we have some coverage for that part.

And actually, that makes the add/sub part of this seem suspicious and probably worth splitting into a separate patch. I think those cases should be calling foldOpWithConstantIntoOperand() to cover both selects and phis.

craig.topper retitled this revision from [InstCombine] Support folding add/and/or/xor with a constant vector RHS into selects to [InstCombine] Support folding and/or/xor with a constant vector RHS into selects and phis.
craig.topper edited the summary of this revision. (Show Details)

Reduced to just the logic operations. Updated tests to include phis

craig.topper edited the summary of this revision. (Show Details)Apr 4 2017, 12:42 PM
spatel accepted this revision.Apr 4 2017, 1:25 PM

LGTM. It would be nice to hoist transforms that are common to all of the bitwise logic ops into a shared helper as an NFC follow-up, so we're not duplicating code. We have something like that for the shift instructions.

This revision is now accepted and ready to land.Apr 4 2017, 1:25 PM

Agreed. I'll do that.

This revision was automatically updated to reflect the committed changes.