aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2015-05-19 23:06:30 +0000
committerHans Wennborg <hans@hanshq.net>2015-05-19 23:06:30 +0000
commit2f21b8760e895242e6827a03e4641e0886dbd385 (patch)
treed549dba43863f39366d7fccc0e9b47029a52d046 /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
parent3de417f40836c6302449ca0eaafbf05a5c863e33 (diff)
downloadllvm-2f21b8760e895242e6827a03e4641e0886dbd385.zip
llvm-2f21b8760e895242e6827a03e4641e0886dbd385.tar.gz
llvm-2f21b8760e895242e6827a03e4641e0886dbd385.tar.bz2
Revert r237539: "Reapply r237520 with another fix for infinite looping"
This caused PR23583. llvm-svn: 237739
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index d2fbcdd..b13d3ed 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1154,30 +1154,18 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
}
// See if we can fold the select into one of our operands.
- if (SI.getType()->isIntOrIntVectorTy()) {
+ if (SI.getType()->isIntegerTy()) {
if (Instruction *FoldI = FoldSelectIntoOp(SI, TrueVal, FalseVal))
return FoldI;
Value *LHS, *RHS, *LHS2, *RHS2;
- Instruction::CastOps CastOp;
- SelectPatternFlavor SPF = matchSelectPattern(&SI, LHS, RHS, &CastOp);
+ SelectPatternFlavor SPF = matchSelectPattern(&SI, LHS, RHS);
+ // MAX(MAX(a, b), a) -> MAX(a, b)
+ // MIN(MIN(a, b), a) -> MIN(a, b)
+ // MAX(MIN(a, b), a) -> a
+ // MIN(MAX(a, b), a) -> a
if (SPF) {
- // Canonicalize so that type casts are outside select patterns.
- if (LHS->getType()->getPrimitiveSizeInBits() !=
- SI.getType()->getPrimitiveSizeInBits()) {
- CmpInst::Predicate Pred = getICmpPredicateForMinMax(SPF);
- Value *Cmp = Builder->CreateICmp(Pred, LHS, RHS);
- Value *NewSI = Builder->CreateCast(CastOp,
- Builder->CreateSelect(Cmp, LHS, RHS),
- SI.getType());
- return ReplaceInstUsesWith(SI, NewSI);
- }
-
- // MAX(MAX(a, b), a) -> MAX(a, b)
- // MIN(MIN(a, b), a) -> MIN(a, b)
- // MAX(MIN(a, b), a) -> a
- // MIN(MAX(a, b), a) -> a
if (SelectPatternFlavor SPF2 = matchSelectPattern(LHS, LHS2, RHS2))
if (Instruction *R = FoldSPFofSPF(cast<Instruction>(LHS),SPF2,LHS2,RHS2,
SI, SPF, RHS))