From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1256) id 446923858CDA; Wed, 22 Nov 2023 01:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 446923858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1700616225; bh=tbYFucH44eu04pEirMhxn9wl2AWHfxLNWYlA2e0EzDw=; h=From:To:Subject:Date:From; b=BcjPQt7Nu0Fs1KMVPSyrMRulM9OIxdJTWt67l1WumBtYlgnCMzRi6qhWuqU6hgUUj ugND7Y6UNNIZGWezIcoMBWOUlwa7BY3G7Wiwdg5Wi5ItaHGC2hi7iGa3/DmB2TDCEi aWHQzf7TAyD2tDtv8C8KXq8tFXrBZz8euPQB01uU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Maciej W. Rozycki To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-5731] RISC-V: Only use SUBREG if applicable in `riscv_expand_float_scc' X-Act-Checkin: gcc X-Git-Author: Maciej W. Rozycki X-Git-Refname: refs/heads/master X-Git-Oldrev: 5e6903ddd39e058b9a8304a77765529d64819966 X-Git-Newrev: 7e126d8d0fbe5677070f02c32a1425849ce36298 Message-Id: <20231122012345.446923858CDA@sourceware.org> Date: Wed, 22 Nov 2023 01:23:45 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7e126d8d0fbe5677070f02c32a1425849ce36298 commit r14-5731-g7e126d8d0fbe5677070f02c32a1425849ce36298 Author: Maciej W. Rozycki Date: Wed Nov 22 01:18:29 2023 +0000 RISC-V: Only use SUBREG if applicable in `riscv_expand_float_scc' A subsequent change to enable the processing of conditional moves on a floating-point condition by `riscv_expand_conditional_move' will cause `riscv_expand_float_scc' to be called for word-mode target RTX with RV64 targets. In that case an invalid insn such as: (insn 25 24 0 (set (reg:DI 141) (subreg:SI (reg:DI 143) 0)) -1 (nil)) would be produced, which would crash the compiler later on. Since the output operand of the SET operation to be produced already has the same mode as the input operand does, just omit the use of SUBREG and assign directly. gcc/ * config/riscv/riscv.cc (riscv_expand_float_scc): Suppress the use of SUBREG if the conditional-set target is word-mode. Diff: --- gcc/config/riscv/riscv.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index df08e9c831a..14e54939291 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4100,7 +4100,9 @@ riscv_expand_float_scc (rtx target, enum rtx_code code, rtx op0, rtx op1) riscv_emit_float_compare (&code, &op0, &op1); rtx cmp = riscv_force_binary (word_mode, code, op0, op1); - riscv_emit_set (target, lowpart_subreg (SImode, cmp, word_mode)); + if (GET_MODE (target) != word_mode) + cmp = lowpart_subreg (GET_MODE (target), cmp, word_mode); + riscv_emit_set (target, cmp); } /* Jump to LABEL if (CODE OP0 OP1) holds. */