[llvm] ValueTracking: Do not look at users of constants for ephemeral values (PR #134618)

via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 05:15:25 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-analysis

Author: Matt Arsenault (arsenm)

<details>
<summary>Changes</summary>

These can only be instructions

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


1 Files Affected:

- (modified) llvm/lib/Analysis/ValueTracking.cpp (+7-2) 


``````````diff
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 3b0249f91d6d7..111515e685d61 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -472,8 +472,13 @@ static bool isEphemeralValueOf(const Instruction *I, const Value *E) {
                      !cast<Instruction>(V)->mayHaveSideEffects() &&
                      !cast<Instruction>(V)->isTerminator())) {
        EphValues.insert(V);
-       if (const User *U = dyn_cast<User>(V))
-         append_range(WorkSet, U->operands());
+
+       if (const User *U = dyn_cast<User>(V)) {
+         for (const Use &U : U->operands()) {
+           if (!isa<Constant>(U))
+             WorkSet.push_back(U.get());
+         }
+       }
       }
     }
   }

``````````

</details>


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


More information about the llvm-commits mailing list