From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1669640756; x=1701176756; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PpKV7z922xD7bVF11mIEtJt9eqw1Lam6+twJMv4bW7U=; b=lG4U8f5Ef2YmPp52YfbOAD1z4pfLGHoKs5sMMeikduY16BamKywsWxqp keXf6O6+hkee4nwC7bEVLVhTjOV8NZs7JQ+ZIp3wgTfLSyi16QwZ8yOZJ md8NXhrr4cZ7dCnEkBWv8SO5HpfT57589cR8GpkEhJ+ereEfFzt+qm5ZL wZOlQTH0oHtwvgaRflOdNpnTq2yCLYG+h35wZ5/4W8IBQRE8BGk5xtX9w 3CSDUaapEkwF0oVoMz7FVaYxcovS9zKArxN1dwtamNeOeyHKf+fhYf+AF VWJXk9sBucrwxGr5hr62xvObVbTrr6VLVu8Wu8/Lmgovz8otglR5aYjfi Q==; 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) From: liuhongt 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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); +} -- 2.27.0