We know that -x & 1 is equivalent to x & 1, avoid using negation for testing if a negative integer is even or odd.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
1277 ↗ | (On Diff #32580) | 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. |
1278 ↗ | (On Diff #32580) | No need for the extra braces as the condition is guarding a single statement. |
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
1276–1278 ↗ | (On Diff #32580) | I think this can more concisely written as: if (AndRHSMask == 1 && match(Op0LHS, m_Zero())) return BinaryOperator::CreateAnd(Op0RHS, AndRHS); |
Comment Actions
LGTM
test/Transforms/InstCombine/and-with-one.ll | ||
---|---|---|
1–25 ↗ | (On Diff #32585) | Instead of a new file, can you add these to and2.ll ? |
Comment Actions
Balaram,
Please let me know when you're ready for the patch to land and I'll be happy to commit it on your behalf.