[all-commits] [llvm/llvm-project] 3dd319: [LoongArch] Optimize conditional selection of integer
Lu Weining via All-commits
all-commits at lists.llvm.org
Tue Jun 20 06:55:54 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3dd319ecf3be64598ea84d1730033854cade7123
https://github.com/llvm/llvm-project/commit/3dd319ecf3be64598ea84d1730033854cade7123
Author: Weining Lu <luweining at loongson.cn>
Date: 2023-06-20 (Tue, 20 Jun 2023)
Changed paths:
M llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
M llvm/test/CodeGen/LoongArch/atomicrmw-uinc-udec-wrap.ll
M llvm/test/CodeGen/LoongArch/ir-instruction/select-bare-int.ll
Log Message:
-----------
[LoongArch] Optimize conditional selection of integer
This patch optimizes code generation by leveraging the zeroing behavior of the `maskeqz`/`masknez` instructions.
```
int sel(int a, int b)
{
return (a < b) ? a : 0;
}
```
```
slt $a1,$a0,$a1
masknez $a2,$r0,$a1
maskeqz $a0,$a0,$a1
or $a0,$a0,$a2
```
=>
```
slt $a1,$a0,$a1
maskeqz $a0,$a0,$a1
```
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D153193
More information about the All-commits
mailing list