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
Event Timeline
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
1276–1278 | 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 | ||
---|---|---|
2–26 | 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.
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.