This patch implements transform for pattern "(A ^ B) | ((~A) ^ B) -> True".

Please help in reviewing the same.

Thanks,

Sonam.

Differential D4691
Added InstCombine transform for pattern "(A ^ B) | ((~A) ^ B) -> True". sonamkumari on Jul 27 2014, 11:42 PM.
Details - Reviewers
majnemer nicholas suyog • espindola
This patch implements transform for pattern "(A ^ B) | ((~A) ^ B) -> True". Please help in reviewing the same. Thanks,
Diff Detail ## Event TimelineComment Actions Hi David, Thanks for your valuable review comments. Thanks, Comment Actions Thinking about this with some colleagues, I'm starting to believe that this can be fixed in a more general way. We do not optimize
Comment Actions I've gone ahead and fixed this in rL214342; it includes a more general transform which should handle more cases. Comment Actions Hi David, Thanks for your valuable comments.I will try to consider general case while doing any optimization in future. The test cases for which it fails are : define i32 @test14(i32 %x, i32 %y) { %nega = xor i32 %x, -1 %xor = xor i32 %nega, %y %xor1 = xor i32 %x, %y %or = or i32 %xor, %xor1 ret i32 %or } define i32 @test15(i32 %x, i32 %y) { %xor = xor i32 %x, %y %nega = xor i32 %x, -1 %xor1 = xor i32 %nega, %y %or = or i32 %xor, %xor1 ret i32 %or } So, I modified the patch and submitting the same. Thanks, Comment Actions I don't think we need to do anything here, running reassociate before instcombine cleans things up. $ cat t.ll define i32 @test14(i32 %x, i32 %y) { %nega = xor i32 %x, -1 %xor = xor i32 %nega, %y %xor1 = xor i32 %x, %y %or = or i32 %xor, %xor1 ret i32 %or } define i32 @test15(i32 %x, i32 %y) { %xor = xor i32 %x, %y %nega = xor i32 %x, -1 %xor1 = xor i32 %nega, %y %or = or i32 %xor, %xor1 ret i32 %or } $ ~/llvm/Debug+Asserts/bin/opt -reassociate -instcombine t.ll -o - -S ; ModuleID = 't.ll' define i32 @test14(i32 %x, i32 %y) { ret i32 -1 } define i32 @test15(i32 %x, i32 %y) { ret i32 -1 } |