[gcc(refs/vendors/riscv/heads/gcc-15-with-riscv-opts)] RISC-V: Combine vec_duplicate + vmslt.vv to vmslt.vx on GR2VR cost
Jeff Law
law@gcc.gnu.org
Fri Jan 30 07:12:43 GMT 2026
https://gcc.gnu.org/g:1e5e925c382649ed7bd0747ccdc30955fe96de35
commit 1e5e925c382649ed7bd0747ccdc30955fe96de35
Author: Pan Li <pan2.li@intel.com>
Date: Mon Dec 8 20:45:56 2025 +0800
RISC-V: Combine vec_duplicate + vmslt.vv to vmslt.vx on GR2VR cost
This patch would like to combine the vec_duplicate + vmslt.wv to the
vmslt.vx. From example as below code. The related pattern will depend
on the cost of vec_duplicate from GR2VR. Then the late-combine will
take action if the cost of GR2VR is zero, and reject the combination
if the GR2VR cost is greater than zero.
Assume we have asm code like below, GR2VR cost is 0.
Before this patch:
11 beq a3,zero,.L8
12 vsetvli a5,zero,e32,m1,ta,ma
13 vmv.v.x v2,a2
...
16 .L3:
17 vsetvli a5,a3,e32,m1,ta,ma
...
22 vmslt.vv v1,v2,v3
...
25 bne a3,zero,.L3
After this patch:
11 beq a3,zero,.L8
...
14 .L3:
15 vsetvli a5,a3,e32,m1,ta,ma
...
20 vmslt.vx v1,a2,v3
...
23 bne a3,zero,.L3
gcc/ChangeLog:
* config/riscv/predicates.md: Append operator lt to
the comparison_swappable_operator.
* config/riscv/riscv-v.cc (get_swapped_cmp_rtx_code): Add
swappable operator lt handing.
Signed-off-by: Pan Li <pan2.li@intel.com>
(cherry picked from commit d1f755115b4a53e866b7eb7a78df9bb2ff28d53a)
Diff:
---
gcc/config/riscv/predicates.md | 2 +-
gcc/config/riscv/riscv-v.cc | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md
index 3cc954e10cc6..5b44165ec993 100644
--- a/gcc/config/riscv/predicates.md
+++ b/gcc/config/riscv/predicates.md
@@ -612,7 +612,7 @@
(match_code "eq,ne,le,leu,gt,gtu,lt,ltu"))
(define_predicate "comparison_swappable_operator"
- (match_code "gtu"))
+ (match_code "gtu,gt"))
(define_predicate "ge_operator"
(match_code "ge,geu"))
diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index fbf2e7a5c464..f3c44313967c 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -5917,6 +5917,8 @@ get_swapped_cmp_rtx_code (rtx_code code)
{
case GTU:
return LTU;
+ case GT:
+ return LT;
default:
gcc_unreachable ();
}
More information about the Gcc-cvs
mailing list