diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2006-09-11 17:23:34 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2006-09-11 17:23:34 +0000 |
commit | 3fc68ccd83d885d500f8d43cd5a7ac962a29b1e7 (patch) | |
tree | a5884c87d5da2a23d5b468b6ee04035790ba953e /lib/Transforms | |
parent | 996f7050dbb735a07ac4c4bad213d0d343d7b1cf (diff) |
Skip the linear search if the answer is already known.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30251 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/PredicateSimplifier.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index d59f71853a..42ae6adbb4 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -501,30 +501,32 @@ Value *PredicateSimplifier::resolve(SetCondInst *SCI, Value *SCI0 = resolve(SCI->getOperand(0), KP), *SCI1 = resolve(SCI->getOperand(1), KP); - PropertySet::ConstPropertyIterator NE = - KP.findProperty(PropertySet::NE, SCI0, SCI1); - - if (NE != KP.Properties.end()) { - switch (SCI->getOpcode()) { - case Instruction::SetEQ: - return ConstantBool::False; - case Instruction::SetNE: - return ConstantBool::True; - case Instruction::SetLE: - case Instruction::SetGE: - case Instruction::SetLT: - case Instruction::SetGT: - break; - default: - assert(0 && "Unknown opcode in SetCondInst."); - break; - } - } ConstantIntegral *CI1 = dyn_cast<ConstantIntegral>(SCI0), *CI2 = dyn_cast<ConstantIntegral>(SCI1); - if (!CI1 || !CI2) return SCI; + if (!CI1 || !CI2) { + PropertySet::ConstPropertyIterator NE = + KP.findProperty(PropertySet::NE, SCI0, SCI1); + + if (NE != KP.Properties.end()) { + switch (SCI->getOpcode()) { + case Instruction::SetEQ: + return ConstantBool::False; + case Instruction::SetNE: + return ConstantBool::True; + case Instruction::SetLE: + case Instruction::SetGE: + case Instruction::SetLT: + case Instruction::SetGT: + break; + default: + assert(0 && "Unknown opcode in SetCondInst."); + break; + } + } + return SCI; + } switch(SCI->getOpcode()) { case Instruction::SetLE: |