[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.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 14 09:59:00 PDT 2016


mcrosier added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1344
@@ +1343,3 @@
+  // the ~V.
+  if (!isa<CmpInst>(V) && !isa<BinaryOperator>(V))
+    return false;
----------------
mcrosier wrote:
> Perhaps you could move the isa<BinaryOperator> check into a separate if statement.  IMO, it doesn't go with the comment above.
Ignore this comment.. :)

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1349
@@ +1348,3 @@
+  // - Constant) - A` if we are willing to invert some of the uses.
+  if (BinaryOperator *BO = dyn_cast<BinaryOperator>(V))
+    if (BO->getOpcode() == Instruction::Add ||
----------------
mcrosier wrote:
> This can be a cast<> rather than a dyn_cast<> because you've already checked we have a BO.
> 
> Alternatively, you could do the following to address the previous comment:
> 
>   BinaryOperator *BO = dyn_cast<BinaryOperator>(V);
>   if (!BO)
>     return false;
> 
> This will also decrease the indention.
Ignore this one too.. 


http://reviews.llvm.org/D16978





More information about the llvm-commits mailing list