summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-01-09 16:00:11 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-01-09 16:00:11 +0000
commitcc21c4aa984c45aed1efcbcdc29c99124c89771e (patch)
tree0a55def747fe4a672e1f1543cae612a184d9c669 /llvm/lib
parentbc453f6e188ef042f5ab32cc8db5979972a5ea94 (diff)
downloadbcm5719-llvm-cc21c4aa984c45aed1efcbcdc29c99124c89771e.tar.gz
bcm5719-llvm-cc21c4aa984c45aed1efcbcdc29c99124c89771e.zip
Instcombine: Fix pattern where the sext did not dominate the icmp using it
llvm-svn: 123121
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 71a286ef69c..ff41ab834b1 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -281,8 +281,8 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
Value *FalseVal = SI.getFalseValue();
// Check cases where the comparison is with a constant that
- // can be adjusted to fit the min/max idiom. We may edit ICI in
- // place here, so make sure the select is the only user.
+ // can be adjusted to fit the min/max idiom. We may move or edit ICI
+ // here, so make sure the select is the only user.
if (ICI->hasOneUse())
if (ConstantInt *CI = dyn_cast<ConstantInt>(CmpRHS)) {
// X < MIN ? T : F --> F
@@ -364,6 +364,11 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI,
ICI->setOperand(1, CmpRHS);
SI.setOperand(1, TrueVal);
SI.setOperand(2, FalseVal);
+
+ // Move ICI instruction right before the select instruction. Otherwise
+ // the sext/zext value may be defined after the ICI instruction uses it.
+ ICI->moveBefore(&SI);
+
Changed = true;
break;
}
OpenPOWER on IntegriCloud