From: Chris Lattner Date: Thu, 21 Apr 2005 05:43:13 +0000 (+0000) Subject: Instcombine this: X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=956db27a63a5f105c12787098dbe713747ed0528;p=oota-llvm.git Instcombine this: %shortcirc_val = select bool %tmp.1, bool true, bool %tmp.4 ; [#uses=1] %tmp.6 = cast bool %shortcirc_val to int ; [#uses=1] into this: %shortcirc_val = or bool %tmp.1, %tmp.4 ; [#uses=1] %tmp.6 = cast bool %shortcirc_val to int ; [#uses=1] not this: %tmp.4.cast = cast bool %tmp.4 to int ; [#uses=1] %tmp.6 = select bool %tmp.1, int 1, int %tmp.4.cast ; [#uses=1] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21389 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 6c1284cbd52..fcdd73d0a66 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -548,6 +548,9 @@ static Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI, Value *FV = SI->getOperand(2); if (isa(TV) || isa(FV)) { + // Bool selects with constant operands can be folded to logical ops. + if (SI->getType() == Type::BoolTy) return 0; + Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, IC); Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, IC);