[llvm] ARM: Avoid relying on kill flags for determining CPSR liveness (PR #222873)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 02:30:23 PDT 2026


================
@@ -1908,10 +1908,14 @@ bool ARMConstantIslands::optimizeThumb2Branches() {
     ImmCmp.MI = nullptr;
     ImmCmp.NewOpc = 0;
 
-    // If the conditional branch doesn't kill CPSR, then CPSR can be liveout
-    // so this transformation is not safe.
-    if (!Br.MI->killsRegister(ARM::CPSR, /*TRI=*/nullptr))
-      return false;
+    // Folding the compare into a CBZ/CBNZ clobbers the comparison, so it is not
+    // safe if CPSR is live past the branch.
+    //
+    // TODO: This could be safe if it's only live into this branch's target.
----------------
arsenm wrote:

```suggestion
```

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


More information about the llvm-commits mailing list