summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-04-08 16:51:49 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-04-08 16:51:49 +0000
commit56737722e43464b896b9e7e628a8c3ce841da605 (patch)
tree5b27438b2d70b1bc1fa4388087e981498e17985b /llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
parent6d6d6af2263c917c2f9a4b8260dbac4d7c6e07b4 (diff)
downloadbcm5719-llvm-56737722e43464b896b9e7e628a8c3ce841da605.tar.gz
bcm5719-llvm-56737722e43464b896b9e7e628a8c3ce841da605.zip
[InstCombine] Fix miscompile in FoldSPFofSPF
We had a select of a cast of a select but attempted to replace the outer select with the inner select dispite their incompatible types. Patch by Anton Korobeynikov! This fixes PR27236. llvm-svn: 265805
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 7260dd2093d..8595996c29c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -642,6 +642,9 @@ Instruction *InstCombiner::FoldSPFofSPF(Instruction *Inner,
Value *A, Value *B,
Instruction &Outer,
SelectPatternFlavor SPF2, Value *C) {
+ if (Outer.getType() != Inner->getType())
+ return nullptr;
+
if (C == A || C == B) {
// MAX(MAX(A, B), B) -> MAX(A, B)
// MIN(MIN(a, b), a) -> MIN(a, b)
OpenPOWER on IntegriCloud