[llvm] [LSR] If there still has some uses of the value, do not set the value (PR #84777)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 09:03:34 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: CL (coderchenlin)

<details>
<summary>Changes</summary>

with nullpter.

---
Full diff: https://github.com/llvm/llvm-project/pull/84777.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Utils/Local.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index d3bb89075015e9..2f97de6bb046e4 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -588,10 +588,10 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(
     // dead as we go.
     for (Use &OpU : I->operands()) {
       Value *OpV = OpU.get();
-      OpU.set(nullptr);
-
       if (!OpV->use_empty())
         continue;
+      
+      OpU.set(nullptr);
 
       // If the operand is an instruction that became dead as we nulled out the
       // operand, and if it is 'trivially' dead, delete it in a future loop

``````````

</details>


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


More information about the llvm-commits mailing list