From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2078) id C151C3858024; Thu, 1 Dec 2022 03:31:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C151C3858024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669865515; bh=VwzGkR6pPt1wIVqZhUP3B7AhbsvJA/AGsZgDxBA8g0A=; h=From:To:Subject:Date:From; b=La47u7Szy8nLDh8rAu3cHyJ0faoM25Gm/Uai88wioJ8AaVFdmVGR2H7BoR3QlcVEk dg+TXpqpocXR8mOeIclXcKmm5k5ZkqSk1vv7LevAJpQX5vBUwDvqJx4d740xB1uuAZ aOHE/iK8qIqWu+x2Ytxj2xsqa5Ph7Eb9RbMiqCnw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: hongtao Liu To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4432] Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode. X-Act-Checkin: gcc X-Git-Author: liuhongt X-Git-Refname: refs/heads/master X-Git-Oldrev: eaaf97b6147095cc19f7efdefaf55c8ebe7a94e8 X-Git-Newrev: cda29c540037fbcf00a377196050953aab1d3d5b Message-Id: <20221201033155.C151C3858024@sourceware.org> Date: Thu, 1 Dec 2022 03:31:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cda29c540037fbcf00a377196050953aab1d3d5b commit r13-4432-gcda29c540037fbcf00a377196050953aab1d3d5b Author: liuhongt Date: Mon Nov 28 09:59:47 2022 +0800 Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode. For __builtin_ia32_vec_set_v16qi (a, -1, 2) with !flag_signed_char. it's transformed to __builtin_ia32_vec_set_v16qi (_4, 255, 2) in the gimple, and expanded to (const_int 255) in the rtl. But for immediate_operand, it expects (const_int 255) to be signed extended to (const_int -1). The mismatch caused an unrecognizable insn error. The patch converts (const_int 255) to (const_int -1) in the backend expander. gcc/ChangeLog: PR target/107863 * config/i386/i386-expand.cc (ix86_expand_vec_set_builtin): Convert op1 to target mode whenever mode mismatch. gcc/testsuite/ChangeLog: * gcc.target/i386/pr107863.c: New test. Diff: --- gcc/config/i386/i386-expand.cc | 2 +- gcc/testsuite/gcc.target/i386/pr107863.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index d26e7e41445..ec3921bdc62 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -12476,7 +12476,7 @@ ix86_expand_vec_set_builtin (tree exp) op1 = expand_expr (arg1, NULL_RTX, mode1, EXPAND_NORMAL); elt = get_element_number (TREE_TYPE (arg0), arg2); - if (GET_MODE (op1) != mode1 && GET_MODE (op1) != VOIDmode) + if (GET_MODE (op1) != mode1) op1 = convert_modes (mode1, GET_MODE (op1), op1, true); op0 = force_reg (tmode, op0); diff --git a/gcc/testsuite/gcc.target/i386/pr107863.c b/gcc/testsuite/gcc.target/i386/pr107863.c new file mode 100644 index 00000000000..99fd85d9765 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr107863.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx2 -O" } */ + +typedef char v16qi __attribute__((vector_size(16))); + +v16qi foo(v16qi a){ + return __builtin_ia32_vec_set_v16qi (a, -1, 2); +}