diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-28 19:18:16 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-05-28 19:18:16 +0000 |
commit | b8743a9150ea41edd8b076f3fd4eb004d3b1350f (patch) | |
tree | c687933f475edb39ba57c8c1ecdaae075d82ff4b /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | |
parent | 1ab17ed57e388450a2fb4465c69894353b9caa40 (diff) | |
download | bcm5719-llvm-b8743a9150ea41edd8b076f3fd4eb004d3b1350f.tar.gz bcm5719-llvm-b8743a9150ea41edd8b076f3fd4eb004d3b1350f.zip |
InstCombine: Fix infinite loop when encountering switch on trivial icmp.
The test case feeds the following into InstCombine's visitSelect:
%tobool8 = icmp ne i32 0, 0
%phitmp = select i1 %tobool8, i32 3, i32 0
Then instcombine replaces the right side of the switch with 0, doesn't notice
that nothing changes and tries again indefinitely.
This fixes PR12897.
llvm-svn: 157587
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index e727b2c592d..0ae00ea17a8 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -498,7 +498,7 @@ Instruction *InstCombiner::visitSelectInstWithICmp(SelectInst &SI, // NOTE: if we wanted to, this is where to detect integer MIN/MAX - if (isa<Constant>(CmpRHS)) { + if (CmpRHS != CmpLHS && isa<Constant>(CmpRHS)) { if (CmpLHS == TrueVal && Pred == ICmpInst::ICMP_EQ) { // Transform (X == C) ? X : Y -> (X == C) ? C : Y SI.setOperand(1, CmpRHS); |