[llvm-branch-commits] [llvm] c7afb69 - [AMDGPU] Avoid calling copyFastMathFlags in wrong context

Piotr Sobczak via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 16 01:28:30 PST 2020


Author: Piotr Sobczak
Date: 2020-12-16T10:22:51+01:00
New Revision: c7afb698caf00f0ad0b479f7d2869c119aa3482e

URL: https://github.com/llvm/llvm-project/commit/c7afb698caf00f0ad0b479f7d2869c119aa3482e
DIFF: https://github.com/llvm/llvm-project/commit/c7afb698caf00f0ad0b479f7d2869c119aa3482e.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
index 59c852b01d8b..b668c9d1d56f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
@@ -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);
 }
 


        


More information about the llvm-branch-commits mailing list