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

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 11:17:21 PDT 2015


majnemer added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1276-1278
@@ +1275,5 @@
+        // -x & 1 -> x & 1
+        if (AndRHSMask == 1 && isa<ConstantInt>(Op0LHS)) {
+            const APInt &Op0LHSMask = dyn_cast<ConstantInt>(Op0LHS)->getValue();
+            if (Op0LHSMask == 0) {
+              return BinaryOperator::CreateAnd(Op0RHS, AndRHS);
----------------
I think this can more concisely written as:
  if (AndRHSMask == 1 && match(Op0LHS, m_Zero()))
    return BinaryOperator::CreateAnd(Op0RHS, AndRHS);


http://reviews.llvm.org/D12156





More information about the llvm-commits mailing list