[llvm] [JumpThreading][GVN] Copy metadata when inserting preload into preds (PR #134403)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 01:24:24 PDT 2025


================
@@ -1362,11 +1362,14 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
   // farther than to a predecessor, we need to reuse the code from GVN's PRE.
   // It requires domination tree analysis, so for this simple case it is an
   // overkill.
+  bool TransfersExecution = false;
   if (PredsScanned.size() != AvailablePreds.size() &&
-      !isSafeToSpeculativelyExecute(LoadI))
+      !isSafeToSpeculativelyExecute(LoadI)) {
     for (auto I = LoadBB->begin(); &*I != LoadI; ++I)
       if (!isGuaranteedToTransferExecutionToSuccessor(&*I))
         return false;
+    TransfersExecution = true;
----------------
nikic wrote:

I think we need to always compute TransfersExecution here (even if not safe to speculate), otherwise we'll get the weird situation where marking the load dereferenceable will result in less metadata transfer.

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


More information about the llvm-commits mailing list