This is an archive of the discontinued LLVM Phabricator instance.

InstCombine ((A | ~B) ^ (~A | B)) to A ^ B
ClosedPublic

Authored by mayurp on Aug 13 2014, 7:26 AM.

Details

Summary

Hi,
A patch in instcombine to transform ((A | ~B) ^ (~A | B)) -> A ^ B.
Please review the patch.

Proof
$ cat t.cvc
A, B : BITVECTOR(32);
QUERY BVXOR((A | ~B),(~A |B)) = BVXOR(A,B);
$ cvc3 t.cvc
Valid.

Diff Detail

Repository
rL LLVM

Event Timeline

mayurp updated this revision to Diff 12446.Aug 13 2014, 7:26 AM
mayurp retitled this revision from to InstCombine ((A | ~B) ^ (~A | B)) to A ^ B.
mayurp updated this object.
mayurp edited the test plan for this revision. (Show Details)
mayurp added a reviewer: majnemer.
mayurp added a subscriber: Unknown Object (MLST).
majnemer added inline comments.Aug 13 2014, 4:00 PM
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
2511–2538 ↗(On Diff #12446)

You have what appear to be eight different patterns you are trying to match. Are you sure we need all of them? What happens if you ran a reassociate pass first?

majnemer added inline comments.Aug 13 2014, 4:02 PM
test/Transforms/InstCombine/or-xor.ll
153–161 ↗(On Diff #12446)

Please give these better names.

mayurp updated this revision to Diff 12484.Aug 13 2014, 9:38 PM

Hi David,
With reassociate, the comparisons can be reduced. Modified the patch accordingly. Also modified the test case.
Please review.

Thanks,
Mayur

majnemer accepted this revision.Aug 13 2014, 9:44 PM
majnemer edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Aug 13 2014, 9:44 PM

Hi David,

Thanks a lot for the review. Can you please commit this on my behalf. I dont have commit access as of now.

Thanks,
Mayur

majnemer closed this revision.Aug 13 2014, 11:55 PM
majnemer updated this revision to Diff 12489.

Closed by commit rL215621 (authored by @majnemer).