[PATCH] D12156: Optimize bitwise even/odd test (-x&1 -> x&1) to not use negation.

Chad Rosier via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 11:12:00 PDT 2015


mcrosier added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1277
@@ +1276,3 @@
+        if (AndRHSMask == 1 && isa<ConstantInt>(Op0LHS)) {
+            const APInt &Op0LHSMask = dyn_cast<ConstantInt>(Op0LHS)->getValue();
+            if (Op0LHSMask == 0) {
----------------
The isa<> check removes the need for a dyn_cast.  You can safely use

const APInt &Op0LHSMask = cast<ConstantInt>(Op0LHS)->getValue();

if I'm not mistaken.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1278
@@ +1277,3 @@
+            const APInt &Op0LHSMask = dyn_cast<ConstantInt>(Op0LHS)->getValue();
+            if (Op0LHSMask == 0) {
+              return BinaryOperator::CreateAnd(Op0RHS, AndRHS);
----------------
No need for the extra braces as the condition is guarding a single statement.


http://reviews.llvm.org/D12156





More information about the llvm-commits mailing list