[llvm] [AArch64] Run optimizeTerminators earlier too. (PR #170907)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 07:36:34 PST 2025


hassnaaHamdi wrote:

> > What about cases like this:
> > mov w10, wzr
> > mul x8, x0, x2
> > stp x8, x9, [x4]
> > cbz w10, .LBB2_2
> 
> Do you have an example where you see that come up? Ideally we would propagate the wzr to the cbz, and then this optimization should kick-in.

It's generated out of the mul-overflow test, specifically the BB of `%overflow.no`:
```
declare i32 @error()

define i128 @test3(i128 noundef %x, i128 noundef %y, ptr %out) {
entry:
  %0 = tail call { i128, i1 } @llvm.umul.with.overflow.i128(i128 %x, i128 %y)
  %1 = extractvalue { i128, i1 } %0, 0
  store i128 %1, ptr %out
  %2 = extractvalue { i128, i1 } %0, 1
  br i1 %2, label %if.then, label %cleanup

if.then:
  %call = tail call i32 @error()
  %conv1 = sext i32 %call to i128
  br label %cleanup

cleanup:
  %retval.0 = phi i128 [ %conv1, %if.then ], [ 1, %entry ]
  ret i128 %retval.0
}
```

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


More information about the llvm-commits mailing list