Skip to content

Commit 27e2c54

Browse files
committed
IRBuilder can return optimized Value which may not be an instruction.
Added if check to make sure we have an instruction.
1 parent d4eda9c commit 27e2c54

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,14 +3873,16 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
38733873
if (match(&SI, m_OrdOrUnordFMax(m_Value(X), m_Value(Y)))) {
38743874
Value *BinIntr =
38753875
Builder.CreateBinaryIntrinsic(Intrinsic::maxnum, X, Y, &SI);
3876-
cast<Instruction>(BinIntr)->setHasNoNaNs(FCmp->hasNoNaNs());
3876+
if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))
3877+
BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());
38773878
return replaceInstUsesWith(SI, BinIntr);
38783879
}
38793880

38803881
if (match(&SI, m_OrdOrUnordFMin(m_Value(X), m_Value(Y)))) {
38813882
Value *BinIntr =
38823883
Builder.CreateBinaryIntrinsic(Intrinsic::minnum, X, Y, &SI);
3883-
cast<Instruction>(BinIntr)->setHasNoNaNs(FCmp->hasNoNaNs());
3884+
if (auto *BinIntrInst = dyn_cast<Instruction>(BinIntr))
3885+
BinIntrInst->setHasNoNaNs(FCmp->hasNoNaNs());
38843886
return replaceInstUsesWith(SI, BinIntr);
38853887
}
38863888
}

0 commit comments

Comments
 (0)