[all-commits] [llvm/llvm-project] a75823: [LoongArch] Select V{ADD, SUB}I for operations with...
hev via All-commits
all-commits at lists.llvm.org
Thu Apr 16 20:04:34 PDT 2026
Branch: refs/heads/users/hev/vsubi
Home: https://github.com/llvm/llvm-project
Commit: a758238af63ade203364241ce9906045c3e68672
https://github.com/llvm/llvm-project/commit/a758238af63ade203364241ce9906045c3e68672
Author: WANG Rui <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
Currently, vector add/sub with a negative splat immediate is lowered as a
vector splat followed by a register-register add, 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.
Commit: 0c4cb19077b4061e0464040f5f317c0a42e91789
https://github.com/llvm/llvm-project/commit/0c4cb19077b4061e0464040f5f317c0a42e91789
Author: WANG Rui <wangrui at loongson.cn>
Date: 2026-04-17 (Fri, 17 Apr 2026)
Changed paths:
M llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
Log Message:
-----------
Fix a typo
Commit: 35b981baf3309f15bf0a9b6d746a3fde705d43cb
https://github.com/llvm/llvm-project/commit/35b981baf3309f15bf0a9b6d746a3fde705d43cb
Author: WANG Rui <wangrui at loongson.cn>
Date: 2026-04-17 (Fri, 17 Apr 2026)
Changed paths:
M llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
Log Message:
-----------
Address wanglei's comments
Compare: https://github.com/llvm/llvm-project/compare/84d5a9c43f16...35b981baf330
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