This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] [NFC] refector foldXorOfICmps
ClosedPublic

Authored by Chenbing.Zheng on May 23 2022, 8:39 PM.

Diff Detail

Event Timeline

Chenbing.Zheng created this revision.May 23 2022, 8:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2022, 8:39 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Chenbing.Zheng requested review of this revision.May 23 2022, 8:39 PM
RKSimon added inline comments.May 24 2022, 1:02 AM
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3063

If the if() below fails - doesn't this leave the LHS0/LHS1 operands in a commuted state further down?

Chenbing.Zheng added inline comments.May 24 2022, 1:11 AM
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3063

(LHS0 == RHS1 && LHS1 == RHS0) is true, means (LHS0 == RHS0 && LHS1 == RHS1) must be true.
In other words, if do swap, we must go to the next conditional branch.

I think this is consistent with the original logic.

Chenbing.Zheng added inline comments.May 24 2022, 1:27 AM
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3063

Correct
(LHS0 == RHS1 && LHS1 == RHS0) is true and after swap(LHS0, LHS1), means (LHS0 == RHS0 && LHS1 == RHS1) must be true.

nikic added a subscriber: nikic.May 24 2022, 2:04 AM
nikic added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3063

Aren't you missing a PredL = ICmpInst::getSwappedPredicate(PredL) here?

Chenbing.Zheng added a reviewer: nikic.

address nikic's comment

Chenbing.Zheng marked an inline comment as done.May 24 2022, 7:03 PM
Chenbing.Zheng added inline comments.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
3063

Thanks and done.

nikic accepted this revision.May 25 2022, 1:55 PM

LGTM

This revision is now accepted and ready to land.May 25 2022, 1:55 PM
This revision was landed with ongoing or failed builds.May 25 2022, 8:09 PM
This revision was automatically updated to reflect the committed changes.
Chenbing.Zheng marked an inline comment as done.