diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2017-09-27 17:42:49 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2017-09-27 17:42:49 +0000 |
commit | 022cc6c41e3711c61a86f12ab7bea010ad72ed88 (patch) | |
tree | 7732e01014eba0af125acf592eea3c32c69ddc84 /llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | |
parent | a2eacb3bfc920bde7ea3b5b124cd27da2cc8f14e (diff) | |
download | bcm5719-llvm-022cc6c41e3711c61a86f12ab7bea010ad72ed88.tar.gz bcm5719-llvm-022cc6c41e3711c61a86f12ab7bea010ad72ed88.zip |
[SLP] Fix crash on propagate IR flags for undef operands of min/max
reductions.
If both operands of the newly created SelectInst are Undefs the
resulting operation is also Undef, not SelectInst. It may cause crashes
when trying to propagate IR flags because function expects exactly
SelectInst instruction, nothing else.
llvm-svn: 314323
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 7f767dcc7d6..d201387debd 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -4938,7 +4938,8 @@ class HorizontalReduction { case RK_Max: case RK_UMin: case RK_UMax: - propagateIRFlags(cast<SelectInst>(Op)->getCondition(), ReductionOps[0]); + if (auto *SI = dyn_cast<SelectInst>(Op)) + propagateIRFlags(SI->getCondition(), ReductionOps[0]); propagateIRFlags(Op, ReductionOps[1]); return Op; case RK_None: @@ -4961,8 +4962,10 @@ class HorizontalReduction { case RK_Max: case RK_UMin: case RK_UMax: - propagateIRFlags(cast<SelectInst>(Op)->getCondition(), - cast<SelectInst>(I)->getCondition()); + if (auto *SI = dyn_cast<SelectInst>(Op)) { + propagateIRFlags(SI->getCondition(), + cast<SelectInst>(I)->getCondition()); + } propagateIRFlags(Op, I); return Op; case RK_None: |