From patchwork Mon Nov 28 13:05:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 26741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5651197wrr; Mon, 28 Nov 2022 05:07:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf6If4VYgkdRdIZLM1r7wcaSCCzGz8BDzkXHfo+s2k2C4toXJSj+9ZOyD7Me2FCqNU1CjOqw X-Received: by 2002:a05:6638:4410:b0:363:aec1:9a04 with SMTP id bp16-20020a056638441000b00363aec19a04mr23932993jab.78.1669640850604; Mon, 28 Nov 2022 05:07:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669640850; cv=none; d=google.com; s=arc-20160816; b=y4DfN4f/61wtySIqNSViYnKCgGmJwMj5JwId9Ps5AEgVtD3/zpQ1JwFjWNj8cRA5GQ F9DrpGyFh70FB6TsRdrdzt7+pur5p2MUNvDvlNhObFqej0sdCZBvJ0E3i08SC7Oyxqvv TAnE3nseZhlZyd99WcVPZKrJymS4XkRTHYcKADAGfeOCn2bzm/5i/iPaxO4PdTiS2XmS Xhku7KCJKYdVDfAw1GMLTdGo5gcRbJqKmBV6qACYEB5LLPETgBAE63046SnHwNjcCVU/ INKJxEtCiMVE9Ki4pR6HA3P6LfzDh/Jw513S4dE133uQoSqIwGASIHeEX5JxBJmmRsB+ SzFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=5md9A/xV9aCSQwHe8oLwk5q50X115vEGHEyHCe7ISo4=; b=JI43tZhJAM93sF9CQUaWeZp01YbkcyXaHyJUYe9z8R+FkwVLrfMPh6l2FC+YUo7yrp ielFILhIxGPILwJEL96vfMiHymznWrAFNVE79/g3YJ9TJqOinKarITfTNqqzUOKnjGSv exud/nqHsLklFJp3n2wsgXTIPwau0px84HMcCBJRPQ07jKeBmFtxI6ws7Y3784pvy9Mr YCd42S2ntKcP0tMh2jqb3bU6OFt4W01XZZSeN53bLY77TBTf9LIPdL7WgX9mmSLrbI+8 JKak9O3e3VrUQhUF94PYWoKzlcfiWWvYo9iaWcOxM5SYZk3ZsvuAVwItDKs+YY+ErjPS NxgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Vif5a7Ar; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p6-20020a056402500600b0046b2d74c08csi2413633eda.38.2022.11.28.05.07.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 05:07:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Vif5a7Ar; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4C12A385B19A for ; Mon, 28 Nov 2022 13:07:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C12A385B19A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669640849; bh=5md9A/xV9aCSQwHe8oLwk5q50X115vEGHEyHCe7ISo4=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Vif5a7ArfLJWudXp02KIa8lnlpBjVetzlJlRd1YmPi2ulYgUavL0+1MgrwiVx8E9o ae4JWkZVApaMXytiWDNb5mvblVwSmGzoaNV2X9rYUSvWjYm3v6U2FnA6cRgjEy5ApT ytZO0StP9qcJI2AGB+J3hb31WxQpTiBXG28D2QgY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by sourceware.org (Postfix) with ESMTPS id B20A8385B19A for ; Mon, 28 Nov 2022 13:05:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B20A8385B19A X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="298182006" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="298182006" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2022 05:05:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10544"; a="674217502" X-IronPort-AV: E=Sophos;i="5.96,200,1665471600"; d="scan'208";a="674217502" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga008.jf.intel.com with ESMTP; 28 Nov 2022 05:05:40 -0800 Received: from shliclel4051.sh.intel.com (shliclel4051.sh.intel.com [10.239.240.51]) by shvmail03.sh.intel.com (Postfix) with ESMTP id E3AA11005612; Mon, 28 Nov 2022 21:05:39 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com, ubizjak@gmail.com Subject: [PATCH] [x86] Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode. Date: Mon, 28 Nov 2022 21:05:39 +0800 Message-Id: <20221128130539.2124727-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: liuhongt via Gcc-patches From: liuhongt Reply-To: liuhongt Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750745324433467132?= X-GMAIL-MSGID: =?utf-8?q?1750745324433467132?= 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. expand_expr_real_1 generates (const_int 255) without considering the target mode. I guess it's on purpose, so I'll leave that alone and only change the expander in the backend. After applying convert_modes to (const_int 255), it's transformed to (const_int -1) which fix the issue. Bootstrapped and regtested x86_64-pc-linux-gnu{-m32,}. Ok for trunk(and backport to GCC-10/11/12 release branches)? 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. --- gcc/config/i386/i386-expand.cc | 2 +- gcc/testsuite/gcc.target/i386/pr107863.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr107863.c diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc index 0373c3614a4..c639ee3a9f7 100644 --- a/gcc/config/i386/i386-expand.cc +++ b/gcc/config/i386/i386-expand.cc @@ -12475,7 +12475,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); +}