From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2078) id E7F983858D37; Thu, 1 Dec 2022 03:37:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7F983858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669865824; bh=UuHH+IVgNH/z+4aCgl1MVG6idassILXkziE92nYcgdM=; h=From:To:Subject:Date:From; b=vmlUPeBTLoQhTo5TH/FoAv2rINzM8gOpvhIobXx3AeDzbKjgIDqK0dR3Y5RINEgw1 TRU0wU7g5LNI43LV9sWlT4yyQa7neFWUlmApEmz+3NEjG3jnMzcgG9xq9WD2BFrT3Z dK4l8PjYdcm33X7SYoq0NWP4p9Rgyt+IaH588B48= 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 r10-11105] 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/releases/gcc-10 X-Git-Oldrev: e73b8e2a42a17ae62507eeb0e4aa10682ed195ea X-Git-Newrev: ac30c91a1002ae4049a4773d07d5da41e7bd3138 Message-Id: <20221201033704.E7F983858D37@sourceware.org> Date: Thu, 1 Dec 2022 03:37:04 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ac30c91a1002ae4049a4773d07d5da41e7bd3138 commit r10-11105-gac30c91a1002ae4049a4773d07d5da41e7bd3138 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.c (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.c | 2 +- gcc/testsuite/gcc.target/i386/pr107863.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c index 6075532b8c9..15ea243503a 100644 --- a/gcc/config/i386/i386-expand.c +++ b/gcc/config/i386/i386-expand.c @@ -10955,7 +10955,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); +}