[PATCH] D17583: [InstCombine] transform bitcasted bitwise logic ops with constants (PR26702)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 15:17:01 PST 2016

spatel created this revision.
spatel added reviewers: majnemer, hfinkel, joker.eph.
spatel added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

Given that we're not actually deleting any instructions in the included regression tests, I think we would call this a canonicalization step.

The motivation comes from the example in PR26702:

If we hoist the bitwise logic ahead of the bitcast, the previously unoptimizable example of:
  define <4 x i32> @is_negative(<4 x i32> %x) {
    %lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
    %not = xor <4 x i32> %lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
    %bc = bitcast <4 x i32> %not to <2 x i64>
    %notnot = xor <2 x i64> %bc, <i64 -1, i64 -1>
    %bc2 = bitcast <2 x i64> %notnot to <4 x i32>
    ret <4 x i32> %bc2

Simplifies to the expected:
  define <4 x i32> @is_negative(<4 x i32> %x) {
    %lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
    ret <4 x i32> %lobit



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17583.48985.patch
Type: text/x-patch
Size: 5332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160224/cfd825cc/attachment.bin>

More information about the llvm-commits mailing list