Example:
(A & 14) != 0 and (A & 1) != 0 => ((cttz (A ^ 8)) - 1) > 3
Paths
| Differential D60590
[InstCombine] Simplify more cases of logical ops of masked icmps. AbandonedPublic Authored by shawnl on Apr 11 2019, 2:59 PM.
Details
Summary Example: (A & 14) != 0 and (A & 1) != 0 => ((cttz (A ^ 8)) - 1) > 3
Diff Detail Event Timelineshawnl retitled this revision from Simplify more cases of logical ops of masked icmps. to InstCombine: Simplify more cases of logical ops of masked icmps..Apr 11 2019, 3:05 PM lebedev.ri retitled this revision from InstCombine: Simplify more cases of logical ops of masked icmps. to [InstCombine] Simplify more cases of logical ops of masked icmps..Apr 11 2019, 3:10 PM This revision now requires changes to proceed.Apr 11 2019, 4:03 PM Comment Actions Note to self: If you get the logic reversed in the example, you will get it reversed in the code. Remove dead code. Comment Actions Could you please upload the diff with more context? This is done by passing -U99999 to git diff or whichever command you're using. shawnl retitled this revision from [InstCombine] Simplify more cases of logical ops of masked icmps. to [InstCombine] Add DCE to VisitAnd. Comment ActionsThere is a bunch of work to be done here, but here is a patch to get started Comment Actions [InstCombine] Simplify more cases of logical ops of masked icmps. Generalizing the work by Hiroshi Yamauchi in Example: (A & 3) == 3 and (A & 4) == 0 => (A & 7) == 3 shawnl retitled this revision from [InstCombine] Add DCE to VisitAnd to [InstCombine] Simplify more cases of logical ops of masked icmps..Apr 12 2019, 5:00 PM
Revision Contents
Diff 194794 lib/Transforms/InstCombine/InstCombineAndOrXor.cpptest/Transforms/InstSimplify/AndOrXor.ll
|
This transform doesn't make any sense to me. (icmp eq (A & 3), 0) && (icmp ne (A & 4), 0) is the same as (icmp eq (A & 7) == 4). Which is exactly the expansion we produce for a cttz equality check in https://github.com/llvm-mirror/llvm/blob/3f5d54bc7b3a850a2df14a6f7b7d8661423d824f/lib/Transforms/InstCombine/InstCombineCompares.cpp#L2851-L2866. Using a mask is more efficient and analyzable than using cttz.