public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMSET
@ 2023-07-14  2:33 Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-07-14  2:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1ed8be53af8cb403a5f79d3a6593baf04fc11e05

commit 1ed8be53af8cb403a5f79d3a6593baf04fc11e05
Author: Pan Li <pan2.li@intel.com>
Date:   Fri Apr 28 23:21:02 2023 +0800

    RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMSET
    
    When some RVV integer compare operators act on the same vector registers
    without mask. They can be simplified to VMSET.
    
    This PATCH allows the eq, le, leu, ge, geu to perform such kind of the
    simplification by adding one macro in riscv for simplify rtx.
    
    Given we have:
    vbool1_t test_shortcut_for_riscv_vmseq_case_0(vint8m8_t v1, size_t vl)
    {
      return __riscv_vmseq_vv_i8m8_b1(v1, v1, vl);
    }
    
    Before this patch:
    vsetvli  zero,a2,e8,m8,ta,ma
    vl8re8.v v8,0(a1)
    vmseq.vv v8,v8,v8
    vsetvli  a5,zero,e8,m8,ta,ma
    vsm.v    v8,0(a0)
    ret
    
    After this patch:
    vsetvli zero,a2,e8,m8,ta,ma
    vmset.m v1                  <- optimized to vmset.m
    vsetvli a5,zero,e8,m8,ta,ma
    vsm.v   v1,0(a0)
    ret
    
    As above, we may have one instruction eliminated and require less vector
    registers.
    
    Signed-off-by: Pan Li <pan2.li@intel.com>
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.h (VECTOR_STORE_FLAG_VALUE): Add new macro
            consumed by simplify_rtx.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c:
            Adjust test check condition.

Diff:
---
 gcc/config/riscv/riscv.h                                            | 5 +++++
 .../gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c       | 6 +-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 13038a39e5c..4473115d3a9 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -1096,4 +1096,9 @@ extern void riscv_remove_unneeded_save_restore_calls (void);
 #define DWARF_REG_TO_UNWIND_COLUMN(REGNO) \
   ((REGNO == RISCV_DWARF_VLENB) ? (FIRST_PSEUDO_REGISTER + 1) : REGNO)
 
+/* Like s390, riscv also defined this macro for the vector comparision.  Then
+   the simplify-rtx relational_result will canonicalize the result to the
+   CONST1_RTX for the simplification.  */
+#define VECTOR_STORE_FLAG_VALUE(MODE) CONSTM1_RTX (GET_MODE_INNER (MODE))
+
 #endif /* ! GCC_RISCV_H */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c b/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
index 8954adad09d..1bca8467a16 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
@@ -283,9 +283,5 @@ vbool64_t test_shortcut_for_riscv_vmsgeu_case_6(vuint8mf8_t v1, size_t vl) {
   return __riscv_vmsgeu_vv_u8mf8_b64(v1, v1, vl);
 }
 
-/* { dg-final { scan-assembler-times {vmseq\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsle\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsleu\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsge\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsgeu\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
 /* { dg-final { scan-assembler-times {vmclr\.m\sv[0-9]} 35 } } */
+/* { dg-final { scan-assembler-times {vmset\.m\sv[0-9]} 35 } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMSET
@ 2023-05-25 23:16 Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-05-25 23:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:75021924c8b0f31d5fc0ca3c72027042fbc41031

commit 75021924c8b0f31d5fc0ca3c72027042fbc41031
Author: Pan Li <pan2.li@intel.com>
Date:   Fri Apr 28 23:21:02 2023 +0800

    RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMSET
    
    When some RVV integer compare operators act on the same vector registers
    without mask. They can be simplified to VMSET.
    
    This PATCH allows the eq, le, leu, ge, geu to perform such kind of the
    simplification by adding one macro in riscv for simplify rtx.
    
    Given we have:
    vbool1_t test_shortcut_for_riscv_vmseq_case_0(vint8m8_t v1, size_t vl)
    {
      return __riscv_vmseq_vv_i8m8_b1(v1, v1, vl);
    }
    
    Before this patch:
    vsetvli  zero,a2,e8,m8,ta,ma
    vl8re8.v v8,0(a1)
    vmseq.vv v8,v8,v8
    vsetvli  a5,zero,e8,m8,ta,ma
    vsm.v    v8,0(a0)
    ret
    
    After this patch:
    vsetvli zero,a2,e8,m8,ta,ma
    vmset.m v1                  <- optimized to vmset.m
    vsetvli a5,zero,e8,m8,ta,ma
    vsm.v   v1,0(a0)
    ret
    
    As above, we may have one instruction eliminated and require less vector
    registers.
    
    Signed-off-by: Pan Li <pan2.li@intel.com>
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.h (VECTOR_STORE_FLAG_VALUE): Add new macro
            consumed by simplify_rtx.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c:
            Adjust test check condition.

Diff:
---
 gcc/config/riscv/riscv.h                                            | 5 +++++
 .../gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c       | 6 +-----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 13038a39e5c..4473115d3a9 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -1096,4 +1096,9 @@ extern void riscv_remove_unneeded_save_restore_calls (void);
 #define DWARF_REG_TO_UNWIND_COLUMN(REGNO) \
   ((REGNO == RISCV_DWARF_VLENB) ? (FIRST_PSEUDO_REGISTER + 1) : REGNO)
 
+/* Like s390, riscv also defined this macro for the vector comparision.  Then
+   the simplify-rtx relational_result will canonicalize the result to the
+   CONST1_RTX for the simplification.  */
+#define VECTOR_STORE_FLAG_VALUE(MODE) CONSTM1_RTX (GET_MODE_INNER (MODE))
+
 #endif /* ! GCC_RISCV_H */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c b/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
index 8954adad09d..1bca8467a16 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/integer_compare_insn_shortcut.c
@@ -283,9 +283,5 @@ vbool64_t test_shortcut_for_riscv_vmsgeu_case_6(vuint8mf8_t v1, size_t vl) {
   return __riscv_vmsgeu_vv_u8mf8_b64(v1, v1, vl);
 }
 
-/* { dg-final { scan-assembler-times {vmseq\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsle\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsleu\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsge\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
-/* { dg-final { scan-assembler-times {vmsgeu\.vv\sv[0-9],\s*v[0-9],\s*v[0-9]} 7 } } */
 /* { dg-final { scan-assembler-times {vmclr\.m\sv[0-9]} 35 } } */
+/* { dg-final { scan-assembler-times {vmset\.m\sv[0-9]} 35 } } */

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-14  2:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-14  2:33 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Allow RVV VMS{Compare}(V1, V1) simplify to VMSET Jeff Law
  -- strict thread matches above, loose matches on Subject: below --
2023-05-25 23:16 Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).