Transform (sub 0, (zext bool to A)) to (sext bool to A) and
(sub 0, (sext bool to A)) to (zext bool to A). Patch by Muhammad Ahmad Reviewed by Duncan Sands llvm-svn: 173093
This commit is contained in:
@@ -1250,6 +1250,16 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
|
||||
|
||||
if (SimplifyDemandedInstructionBits(I))
|
||||
return &I;
|
||||
|
||||
// Fold (sub 0, (zext bool to B)) --> (sext bool to B)
|
||||
if (C->isZero() && match(Op1, m_ZExt(m_Value(X))))
|
||||
if (X->getType()->isIntegerTy(1))
|
||||
return CastInst::CreateSExtOrBitCast(X, Op1->getType());
|
||||
|
||||
// Fold (sub 0, (sext bool to B)) --> (zext bool to B)
|
||||
if (C->isZero() && match(Op1, m_SExt(m_Value(X))))
|
||||
if (X->getType()->isIntegerTy(1))
|
||||
return CastInst::CreateZExtOrBitCast(X, Op1->getType());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user