This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] add vector support for (A >> C) == (B >> C) --> (A^B) u< (1 << C)
ClosedPublic

Authored by Chenbing.Zheng on Jun 9 2022, 4:52 AM.

Diff Detail

Event Timeline

Chenbing.Zheng created this revision.Jun 9 2022, 4:52 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2022, 4:52 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.Jun 9 2022, 4:52 AM
RKSimon added inline comments.Jun 9 2022, 5:20 AM
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4629

Does returning here affect any later combines that could have folded?

Chenbing.Zheng added inline comments.Jun 9 2022, 7:21 PM
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4629

This is the only fold of (A >> AP1) == (B >> AP2) so far, and I think it should be moved here when other same pattern appear.

RKSimon added inline comments.Jun 10 2022, 2:33 AM
llvm/test/Transforms/InstCombine/compare-signs.ll
62

Please can add non-uniform vector tests as well?

rebase precommit tests, and add support for vector's undef

Chenbing.Zheng marked an inline comment as done.Jun 13 2022, 8:46 PM
Chenbing.Zheng added inline comments.
llvm/test/Transforms/InstCombine/compare-signs.ll
78
92

precommit negative tests here

spatel accepted this revision.Jun 17 2022, 7:12 AM

LGTM - see inline for some possible minor improvements.

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4621

"C" in the result is not the same as "C" in the source - update this comment to make the transform clearer?

4642

Do you plan to change this one too? It will be easier to read the code and see the early return if we make a smaller helper function to handle the related patterns.

4659

Another transform that can be updated...

This revision is now accepted and ready to land.Jun 17 2022, 7:12 AM
spatel added inline comments.Jun 17 2022, 7:16 AM
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4621

Sorry - disregard that comment. I misread the transform. This looks fine.

This revision was landed with ongoing or failed builds.Jun 19 2022, 7:58 PM
This revision was automatically updated to reflect the committed changes.