[PATCH] D16978: [InstCombine] Try harder to simplify ~(X & Y) -> ~X | ~Y and ~(X | Y) -> ~X & ~Y when X and Y have more than one uses.

Balaram Makam via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 14:25:50 PST 2016


bmakam marked 3 inline comments as done.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1251-1253
@@ -1250,5 +1250,5 @@
          "Unexpected opcode for bitwise logic folding");
 
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
   CastInst *Cast0 = dyn_cast<CastInst>(Op0);
   if (!Cast0)
----------------
Only supporting for non vector types for now as the codegen for vector types is suboptimal.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1277-1285
@@ -1276,11 +1276,11 @@
   }
 
   CastInst *Cast1 = dyn_cast<CastInst>(Op1);
   if (!Cast1)
     return nullptr;
 
   // Both operands of the logic operation are casts. The casts must be of the
   // same type for reduction.
   auto CastOpcode = Cast0->getOpcode();
   if (CastOpcode != Cast1->getOpcode() || SrcTy != Cast1->getSrcTy())
     return nullptr;
----------------
I have refactored the code after landing D17942. To reduce the amount of work I am now checking only local users.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1291
@@ -1290,3 +1290,3 @@
 
   // fold (logic (cast A), (cast B)) -> (cast (logic A, B))
 
----------------
Refactored code so that Users will always contain instructions.

================
Comment at: test/Transforms/InstCombine/not2.ll:3
@@ +2,3 @@
+; CHECK-NOT: xor
+
+define void @test1(i32 %A, i32 %B, i32 %C) {
----------------
There is nothing more to test in these testcases other than checking if xor has been elided similar to the tests in test/Transforms/InstCombine/not.ll  


http://reviews.llvm.org/D16978





More information about the llvm-commits mailing list