From 701b9309b687ed46188b9caeb7d88ad60b0212e5 Mon Sep 17 00:00:00 2001 From: Juzhe-Zhong Date: Tue, 12 Sep 2023 21:32:02 +0800 Subject: [PATCH] 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_): New pattern. --- 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 e9dd40af9358..50c0104550b3 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_" + [(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, and_optab, operands[1], + operands[3], NULL_RTX, 0, + OPTAB_DIRECT); + /* mask2 = ~operands[3] & operands[2]. */ + rtx inverse = expand_unop (mode, one_cmpl_optab, operands[3], + NULL_RTX, 0); + rtx mask2 = expand_binop (mode, and_optab, operands[2], + inverse, NULL_RTX, 0, + OPTAB_DIRECT); + /* result = mask1 | mask2. */ + rtx result = expand_binop (mode, ior_optab, mask1, + mask2, NULL_RTX, 0, + OPTAB_DIRECT); + emit_move_insn (operands[0], result); + DONE; + }) + ;; ------------------------------------------------------------------------- ;; ---- [INT,FP] Comparisons ;; ------------------------------------------------------------------------- -- 2.47.2