[llvm] [AArch64][CodeGen] Optimize register zero initialization in svsub_x (PR #149840)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 02:59:03 PDT 2025


yafet-a wrote:

I was under the impression SVE intriniscs bypassed InstCombine and only allowed for optimisation during SelectionDAG lowering. I ran gdb on a minimal example with breakpoints throughout TargetTransformInfo and got that it exited normally. Hence my thinking it will only appear during lowering and to keep the optimisation there
```llvm
Breakpoint 1 (AArch64TTIImpl::instCombineIntrinsic) pending.
(gdb) b instCombineSVEVectorSub
Function "instCombineSVEVectorSub" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (instCombineSVEVectorSub) pending.
(gdb) b instCombineSVEVectorFSubU
Function "instCombineSVEVectorFSubU" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 3 (instCombineSVEVectorFSubU) pending.
(gdb) b AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN
Function "AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 4 (AArch64TargetLowering::LowerINTRINSIC_WO_CHAIN) pending.
(gdb) run -S -passes=instcombine /llvm-project/debug_test.ll 
Starting program: llvm-project/build/bin/opt -S -passes=llvm-project/debug_test.ll
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
; ModuleID = 'llvm-project/debug_test.ll'
source_filename = "llvm-project/debug_test.ll"

define <vscale x 4 x i32> @test_direct(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a) {
  %result = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %a)
  ret <vscale x 4 x i32> %result
}

define <vscale x 4 x i32> @test_indirect(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a) {
  %result = call <vscale x 4 x i32> @llvm.aarch64.sve.sub.u.nxv4i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %a)
  ret <vscale x 4 x i32> %result
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(none)
declare <vscale x 4 x i32> @llvm.aarch64.sve.sub.u.nxv4i32(<vscale x 4 x i1>, <vscale x 4 x i32>, <vscale x 4 x i32>) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(none) }
[Inferior 1 (process 2281521) exited normally]
``` 

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


More information about the llvm-commits mailing list