[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:02:43 PDT 2024


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

with nullpter.

>From f30c1e0e0b492b81413080fd100807f4fe51d8a7 Mon Sep 17 00:00:00 2001
From: coderchenlin <chenlin048830 at gmail.com>
Date: Mon, 11 Mar 2024 22:56:08 +0800
Subject: [PATCH] [LSR] If there still has some uses of the value, do not set
 the value with nullpter.

---
 llvm/lib/Transforms/Utils/Local.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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



More information about the llvm-commits mailing list