[llvm] Check for side effects when lowering target intrinsics, update NVVM ldu/ldg intrinsics with IntrWillReturn and test for DCE (PR #98968)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 11:42:50 PDT 2024


================
@@ -5227,7 +5227,7 @@ void SelectionDAGBuilder::visitTargetIntrinsic(const CallInst &I,
   // definition.
   const Function *F = I.getCalledFunction();
   bool HasChain = !F->doesNotAccessMemory();
-  bool OnlyLoad = HasChain && F->onlyReadsMemory();
+  bool OnlyLoad = HasChain && F->onlyReadsMemory() && !I.mayHaveSideEffects();
----------------
arsenm wrote:

I don't understand why willreturn matters in this context. But also, we don't need to repeat every optimization in codegen.

In any case, a patch touching the intrinsic attributes shouldn't be in the same patch as one changing the behavior here 

https://github.com/llvm/llvm-project/pull/98968


More information about the llvm-commits mailing list