This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Refactor foldSelectICmpAndOr to use `decomposeBitTestICmp` instead of bespoke logic
ClosedPublic

Authored by goldstein.w.n on Apr 19 2023, 1:44 PM.

Details

Summary

This is essentially NFC as the cases decomposeBitTestICmp covers
that weren't already covered explicitly, will be canonicalized into
the cases explicitly covered. As well the unsigned cases don't apply
as the Mask is not a power of 2.

That being said, using a well established helper is less bug prone and
if some canonicalization changes, will prevent regressions here.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Apr 19 2023, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 1:44 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Apr 19 2023, 1:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 1:44 PM
nikic added inline comments.Jun 29 2023, 7:21 AM
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
692

Probably better to pass CmpLHS instead of Unused? They'll always be the same without LookThruTrunc, but that seems more robust.

697

I don't really get why this isn't NeedAnd = true any more.

goldstein.w.n marked 2 inline comments as done.Jul 9 2023, 7:09 PM
goldstein.w.n added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
697

Can't remember why I changed that. Probably was a mistake either way.

goldstein.w.n marked an inline comment as done.

Remove Unused variable and remove change to NeedAnd logic

nikic accepted this revision.Jul 10 2023, 3:32 AM

LGTM

This revision is now accepted and ready to land.Jul 10 2023, 3:32 AM