public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Support VECTOR BOOL vcond_mask optab[PR111337]
@ 2023-09-18 18:25 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-09-18 18:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2e365b6b6b7d754860273ab2db104d53777671eb

commit 2e365b6b6b7d754860273ab2db104d53777671eb
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Tue Sep 12 21:32:02 2023 +0800

    RISC-V: Support VECTOR BOOL vcond_mask optab[PR111337]
    
    As this PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111337
    
    We support VECTOR BOOL vcond_mask to fix this following ICE:
    0x1a9e309 gimple_expand_vec_cond_expr
            ../../../../gcc/gcc/gimple-isel.cc:283
    0x1a9ea56 execute
            ../../../../gcc/gcc/gimple-isel.cc:390
    
    gcc/ChangeLog:
    
            PR target/111337
            * config/riscv/autovec.md (vcond_mask_<mode><mode>): New pattern.
    
    (cherry picked from commit 701b9309b687ed46188b9caeb7d88ad60b0212e5)

Diff:
---
 gcc/config/riscv/autovec.md | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md
index e9dd40af935..50c0104550b 100644
--- a/gcc/config/riscv/autovec.md
+++ b/gcc/config/riscv/autovec.md
@@ -565,6 +565,40 @@
   [(set_attr "type" "vector")]
 )
 
+;; -------------------------------------------------------------------------
+;; ---- [BOOL] Select based on masks
+;; -------------------------------------------------------------------------
+;; Includes merging patterns for:
+;; - vmand.mm
+;; - vmor.mm
+;; - vmnot.m
+;; -------------------------------------------------------------------------
+
+(define_expand "vcond_mask_<mode><mode>"
+  [(match_operand:VB 0 "register_operand")
+   (match_operand:VB 1 "register_operand")
+   (match_operand:VB 2 "register_operand")
+   (match_operand:VB 3 "register_operand")]
+  "TARGET_VECTOR"
+  {
+    /* mask1 = operands[3] & operands[1].  */
+    rtx mask1 = expand_binop (<MODE>mode, and_optab, operands[1],
+			      operands[3], NULL_RTX, 0,
+			      OPTAB_DIRECT);
+    /* mask2 = ~operands[3] & operands[2].  */
+    rtx inverse = expand_unop (<MODE>mode, one_cmpl_optab, operands[3],
+			       NULL_RTX, 0);
+    rtx mask2 = expand_binop (<MODE>mode, and_optab, operands[2],
+			      inverse, NULL_RTX, 0,
+			      OPTAB_DIRECT);
+    /* result = mask1 | mask2.  */
+    rtx result = expand_binop (<MODE>mode, ior_optab, mask1,
+			       mask2, NULL_RTX, 0,
+			       OPTAB_DIRECT);
+    emit_move_insn (operands[0], result);
+    DONE;
+  })
+
 ;; -------------------------------------------------------------------------
 ;; ---- [INT,FP] Comparisons
 ;; -------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-18 18:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 18:25 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Support VECTOR BOOL vcond_mask optab[PR111337] 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).