[AMDGPU] Avoid calling copyFastMathFlags in wrong context

Calling Instruction::copyFastMathFlags() assumes the caller is
FPMathOperator. Avoid calling the function for instructions
that are not instances of FPMathOperator.
This commit is contained in:
Piotr Sobczak 2020-12-16 10:12:54 +01:00
parent f141d1afc5
commit c7afb698ca
1 changed files with 2 additions and 1 deletions

View File

@ -159,7 +159,8 @@ simplifyAMDGCNImageIntrinsic(const GCNSubtarget *ST,
CallInst *NewCall = IC.Builder.CreateCall(I, Args);
NewCall->takeName(&II);
NewCall->copyMetadata(II);
NewCall->copyFastMathFlags(&II);
if (isa<FPMathOperator>(NewCall))
NewCall->copyFastMathFlags(&II);
return IC.replaceInstUsesWith(II, NewCall);
}