[AMDGPUCodeGenPrepare] Check result of ConstantFoldBinaryOpOperands()

This function will become fallible once we don't support constant
expressions for all binops, so make sure to check the result.
This commit is contained in:
Nikita Popov 2022-07-04 12:55:42 +02:00
parent 4905bcac00
commit 8e70258b18
1 changed files with 2 additions and 2 deletions

View File

@ -626,13 +626,13 @@ bool AMDGPUCodeGenPrepare::foldBinOpIntoSelect(BinaryOperator &BO) const {
Constant *FoldedT = SelOpNo ?
ConstantFoldBinaryOpOperands(BO.getOpcode(), CBO, CT, *DL) :
ConstantFoldBinaryOpOperands(BO.getOpcode(), CT, CBO, *DL);
if (isa<ConstantExpr>(FoldedT))
if (!FoldedT || isa<ConstantExpr>(FoldedT))
return false;
Constant *FoldedF = SelOpNo ?
ConstantFoldBinaryOpOperands(BO.getOpcode(), CBO, CF, *DL) :
ConstantFoldBinaryOpOperands(BO.getOpcode(), CF, CBO, *DL);
if (isa<ConstantExpr>(FoldedF))
if (!FoldedF || isa<ConstantExpr>(FoldedF))
return false;
IRBuilder<> Builder(&BO);