From 718bf3f89d69f76791fec73b1edd55c450a93f12 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 5 Jan 2010 21:04:47 +0000 Subject: [PATCH] move a zext specific xform out of commonIntCastTransforms into visitZExt and modernize it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92770 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../InstCombine/InstCombineCasts.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index e2bb3fbe04a..4b8c5534dfa 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -645,16 +645,6 @@ Instruction *InstCombiner::commonIntCastTransforms(CastInst &CI) { cast(SrcI)->getOpcode(), Op0c, Op1c); } } - - // cast (xor bool X, true) to int --> xor (cast bool X to int), 1 - if (isa(CI) && SrcBitSize == 1 && - SrcI->getOpcode() == Instruction::Xor && - Op1 == ConstantInt::getTrue(CI.getContext()) && - (!Op0->hasOneUse() || !isa(Op0))) { - Value *New = Builder->CreateZExt(Op0, DestTy, Op0->getName()); - return BinaryOperator::CreateXor(New, - ConstantInt::get(CI.getType(), 1)); - } break; } return 0; @@ -933,6 +923,15 @@ Instruction *InstCombiner::visitZExt(ZExtInst &CI) { } } + // zext (xor i1 X, true) to i32 --> xor (zext i1 X to i32), 1 + Value *X; + if (SrcI && SrcI->getType()->isInteger(1) && + match(SrcI, m_Not(m_Value(X))) && + (!X->hasOneUse() || !isa(X))) { + Value *New = Builder->CreateZExt(X, CI.getType()); + return BinaryOperator::CreateXor(New, ConstantInt::get(CI.getType(), 1)); + } + return 0; }