This is an archive of the discontinued LLVM Phabricator instance.

InstCombine ((x | ~y) ^ (~x ^ y)) to (x & ~y)
Needs ReviewPublic

Authored by mayurp on Aug 16 2014, 1:14 AM.

Details

Reviewers
majnemer
Summary

Hi David,

Another small patch in instcombine. Can you please review the patch.

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

Thanks,
Mayur

Diff Detail

Event Timeline

mayurp updated this revision to Diff 12581.Aug 16 2014, 1:14 AM
mayurp retitled this revision from to InstCombine ((x | ~y) ^ (~x ^ y)) to (x & ~y).
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).
asl added a subscriber: asl.Aug 16 2014, 12:05 PM

I'm really curios - how often such patterns happen in real world code?

Hi Anton,

I think we should not miss out on any optimization opportunity in general. The number of instructions saved in this case is a big win wherever such pattern occurs.
In general most of the patterns handled in Instcombine module are not very commonly used, but still it is better to handle them.

Saying that, I strongly believe that there should be a general approach to combining instructions. A discussion is going on regarding the same at:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-August/075532.html

Thanks,
Mayur

majnemer edited edge metadata.Aug 22 2014, 11:14 AM

This can be generalized:

(X | (Y ^ Z)) ^ ((X ^ Z) ^ Y) -> X & (Y ^ Z)

mayurp updated this revision to Diff 13028.Aug 28 2014, 5:49 AM
mayurp edited edge metadata.

Hi David,

Updated the patch as per your comments to make it more generalized. Please help in reviewing the same.

Thanks,
Mayur