[llvm] [ShrinkWrap] Consider constant pool access as non-stack access (PR #164393)

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 21 07:54:28 PDT 2025


================
@@ -0,0 +1,75 @@
+# RUN: llc -simplify-mir -run-pass=shrink-wrap -o - %s | FileCheck %s
+--- |
+  declare double @foo()
+
+  define double @shrink_wrap_load_from_const_pool(double %q) {
+  entry:
+    %0 = fcmp oeq double %q, 3.125500e+02
+    br i1 %0, label %common.ret, label %if.else
+
+  common.ret:                                       ; preds = %if.else, %entry, %exit1
+    %common.ret.op = phi double [ %3, %exit1 ], [ 0.000000e+00, %entry ], [ 0.000000e+00, %if.else ]
+    ret double %common.ret.op
+
+  if.else:                                          ; preds = %entry
+    %1 = call double @foo()
+    %2 = fcmp oeq double %1, 0.000000e+00
+    br i1 %2, label %exit1, label %common.ret
+
+  exit1:                                            ; preds = %if.else
+    %3 = call double @foo()
+    br label %common.ret
+  }
+...
+# Following code has a load from constant pool. Accessing constant pool
+# must not be considered as a stack access and hence, shrink wrapping must
+# happen.
+# CHECK:  savePoint:
----------------
MatzeB wrote:

anchor with a CHECK-LABEL?
```suggestion
# CHECK-LABEL: name: shrink_wrap_load_from_const_pool
# CHECK:  savePoint:
```

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


More information about the llvm-commits mailing list