[all-commits] [llvm/llvm-project] b3661c: [LoongArch] Select V{ADD, SUB}I for operations with...
hev via All-commits
all-commits at lists.llvm.org
Fri Apr 17 02:46:15 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b3661c2da61c5f2b6cca30a3ca2e66dfdf26acd3
https://github.com/llvm/llvm-project/commit/b3661c2da61c5f2b6cca30a3ca2e66dfdf26acd3
Author: hev <wangrui at loongson.cn>
Date: 2026-04-17 (Fri, 17 Apr 2026)
Changed paths:
M llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
M llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.h
M llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
M llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
M llvm/test/CodeGen/LoongArch/lasx/ir-instruction/add.ll
M llvm/test/CodeGen/LoongArch/lasx/ir-instruction/sub.ll
M llvm/test/CodeGen/LoongArch/lsx/ir-instruction/add.ll
M llvm/test/CodeGen/LoongArch/lsx/ir-instruction/sub.ll
Log Message:
-----------
[LoongArch] Select V{ADD,SUB}I for operations with negative splat immediates (#191966)
Currently, vector add/sub with a negative splat immediate is lowered as
a vector splat followed by a register-register operations, e.g.:
```
vrepli.b $vr1, -1
vadd.b $vr0, $vr0, $vr1
```
This misses the opportunity to use the more efficient V{ADD,SUB}I
instruction with a positive immediate.
This patch introduces `selectVSplatImmNeg` to detect negative splat
immediates whose negated value fits in a 5-bit unsigned immediate. New
patterns `(Pat{Vr,Vr}Nimm5)` are added to match:
```
add v, splat(-imm) --> vsubi v, v, imm
sub v, splat(-imm) --> vaddi v, v, imm
```
This avoids materializing the splat constant and reduces the instruction
count.
The transformation is applied for both LSX and LASX vector types.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list