]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Support VECTOR BOOL vcond_mask optab[PR111337]
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Tue, 12 Sep 2023 13:32:02 +0000 (21:32 +0800)
committerRobin Dapp <rdapp@ventanamicro.com>
Tue, 12 Sep 2023 20:41:57 +0000 (22:41 +0200)
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.

gcc/config/riscv/autovec.md

index e9dd40af93583660efb4854dd2224978c2e568f4..50c0104550b3133b6fc3f13c2be6f50b3595486f 100644 (file)
   [(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
 ;; -------------------------------------------------------------------------