summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2017-12-28 09:35:35 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2017-12-28 09:35:35 +0000
commit472689a159e6e2d455724d28eef35554daa6667b (patch)
treef90a9de5aae25898643acdecd7dcb87e28316655 /llvm
parent5a81bb73ad04277411b007a20a5c95b87c775fe6 (diff)
downloadbcm5719-llvm-472689a159e6e2d455724d28eef35554daa6667b.tar.gz
bcm5719-llvm-472689a159e6e2d455724d28eef35554daa6667b.zip
[InstCombine] Check for isa<Instruction> before using cast<>
Protects against casts from constexpr etc. Reduced from oss-fuzz #4788 test case llvm-svn: 321515
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll13
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 5e0778d9ae2..40e52ee755e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -2376,7 +2376,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// The compare intrinsic uses the above assumptions and therefore
// doesn't require additional flags.
if ((match(Arg0, m_OneUse(m_FSub(m_Value(A), m_Value(B)))) &&
- match(Arg1, m_Zero()) &&
+ match(Arg1, m_Zero()) && isa<Instruction>(Arg0) &&
cast<Instruction>(Arg0)->getFastMathFlags().noInfs())) {
if (Arg0IsZero)
std::swap(A, B);
diff --git a/llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll b/llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
index fde0692d00a..b05b27f533b 100644
--- a/llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
+++ b/llvm/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
@@ -122,6 +122,19 @@ entry:
}
+define i8 @sub_compare_folding_swapPD256_undef(<4 x double> %a, <4 x double> %b) {
+; CHECK-LABEL: @sub_compare_folding_swapPD256_undef(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP:%.*]] = tail call i8 @llvm.x86.avx512.mask.cmp.pd.256(<4 x double> fsub (<4 x double> undef, <4 x double> undef), <4 x double> zeroinitializer, i32 5, i8 -1)
+; CHECK-NEXT: ret i8 [[TMP]]
+;
+entry:
+ %sub.i1 = fsub ninf <4 x double> undef, undef
+ %tmp = tail call i8 @llvm.x86.avx512.mask.cmp.pd.256(<4 x double> %sub.i1, <4 x double> zeroinitializer, i32 5, i8 -1)
+ ret i8 %tmp
+}
+
+
define i8 @sub_compare_folding_swapPD512(<8 x double> %a, <8 x double> %b){
; CHECK-LABEL: @sub_compare_folding_swapPD512(
; CHECK-NEXT: entry:
OpenPOWER on IntegriCloud