From patchwork Fri Jul 26 06:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liuhongt X-Patchwork-Id: 1965199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eWXkwO3H; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WVdsf0R2Gz1ybY for ; Fri, 26 Jul 2024 16:59:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9862D3858420 for ; Fri, 26 Jul 2024 06:59:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by sourceware.org (Postfix) with ESMTPS id A3B3C3858D20 for ; Fri, 26 Jul 2024 06:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A3B3C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A3B3C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721977146; cv=none; b=qszaiQqEyyoMaU7l1mdOy3i+PX3U5uq8W1LZpRo6atQoTsppb3qSq5LUdFN9dpY2M63WK5n0dNLqEFn2Ke4zKVZbLItyj/qxMmjrnwHopC4Mv8vMgwSflqt43cDKcHzvVD90dCrFnuaREPTYZfJ4rzmVUpyWKtJNRWARO3eaADw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721977146; c=relaxed/simple; bh=QpLZinD7IK02X/WFvpoZ1PHhZDa14S5wxyabdNxnJP4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XvtUr62IuyIFkr+ExrNlW5J8sCbsjmhAtz/pgjF0C6iplc6UC1I9lOWyAS+TlgYDpBUAsOA1T/xjJj/TV1pTg/dqBtJBFJzOd39A/oy9hR24MQVT9VQ2UaQxDSLPlrDCDSS7yBWN6vaVFenmbr4GqXzJDrWXtgjEgTOJ6DW3k1g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721977144; x=1753513144; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=QpLZinD7IK02X/WFvpoZ1PHhZDa14S5wxyabdNxnJP4=; b=eWXkwO3H7YeTDwmuzPHFkSW+xegvcJo3pesXKU+0o5tUpMJuyiXpyty2 IiwWABA+5G09r5TPB2ma93YOpZj/YO1wmVNGqvdklhNInG7Fwdyj8b4YT r1XK8i1CPYQHtSd5lB/e+2rfnvETS2bhx+ZTgf5xxRPBM+dFJB1CRdGMC XII+DPOIlswIvwF24yffkuFEEXW35BPj1p0BRleKHX9pFrHK7xx+5PwxI PTW0l0ZpFrmPZPe5SUiIKFfhMUGkDxi/xgzgehXKHSUrPVQYZi8pw8DPh otzyCMCYLsXirss4Wupx3tGzHRFa7+S9EiIBetQ9MNZ+e+i+Uhnm1z2WT Q==; X-CSE-ConnectionGUID: AoAFhLQPSRKr6nWV+cB6dg== X-CSE-MsgGUID: d2s5OrolTFOjgqid6JPplg== X-IronPort-AV: E=McAfee;i="6700,10204,11144"; a="19882085" X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="19882085" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 23:59:03 -0700 X-CSE-ConnectionGUID: 6xYZJwxmT7qV4G9CclDq8w== X-CSE-MsgGUID: bwy4HWzlTBaR9A2ARMP/2g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,238,1716274800"; d="scan'208";a="53110448" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmviesa009.fm.intel.com with ESMTP; 25 Jul 2024 23:59:00 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id BDCB9100567B; Fri, 26 Jul 2024 14:58:59 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] Fix mismatch between constraint and predicate for ashl3_doubleword. Date: Fri, 26 Jul 2024 14:56:59 +0800 Message-Id: <20240726065659.3929919-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org (insn 98 94 387 2 (parallel [ (set (reg:TI 337 [ _32 ]) (ashift:TI (reg:TI 329) (reg:QI 521))) (clobber (reg:CC 17 flags)) ]) "test.c":11:13 953 {ashlti3_doubleword} is reloaded into (insn 98 452 387 2 (parallel [ (set (reg:TI 0 ax [orig:337 _32 ] [337]) (ashift:TI (const_int 1671291085 [0x639de0cd]) (reg:QI 2 cx [521]))) (clobber (reg:CC 17 flags)) since constraint n in the pattern accepts that. (Not sure why reload doesn't check predicate) (define_insn "ashl3_doubleword" [(set (match_operand:DWI 0 "register_operand" "=&r,&r") (ashift:DWI (match_operand:DWI 1 "reg_or_pm1_operand" "0n,r") (match_operand:QI 2 "nonmemory_operand" "c,c"))) The patch fixes the mismatch between constraint and predicate. Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: PR target/116096 * config/i386/constraints.md (BC): Move TARGET_SSE to vector_all_ones_operand. * config/i386/i386.md (ashl3_doubleword): Refine constraint with BC. gcc/testsuite/ChangeLog: * gcc.target/i386/pr116096.c: New test. --- gcc/config/i386/constraints.md | 4 ++-- gcc/config/i386/i386.md | 2 +- gcc/testsuite/gcc.target/i386/pr116096.c | 26 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr116096.c diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md index 7508d7a58bd..fd032c2b9f0 100644 --- a/gcc/config/i386/constraints.md +++ b/gcc/config/i386/constraints.md @@ -225,8 +225,8 @@ (define_constraint "Bz" (define_constraint "BC" "@internal integer SSE constant with all bits set operand." - (and (match_test "TARGET_SSE") - (ior (match_test "op == constm1_rtx") + (ior (match_test "op == constm1_rtx") + (and (match_test "TARGET_SSE") (match_operand 0 "vector_all_ones_operand")))) (define_constraint "BF" diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 6207036a2a0..9c4e847fba1 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -14774,7 +14774,7 @@ (define_insn_and_split "*ashl3_doubleword_mask_1" (define_insn "ashl3_doubleword" [(set (match_operand:DWI 0 "register_operand" "=&r,&r") - (ashift:DWI (match_operand:DWI 1 "reg_or_pm1_operand" "0n,r") + (ashift:DWI (match_operand:DWI 1 "reg_or_pm1_operand" "0BC,r") (match_operand:QI 2 "nonmemory_operand" "c,c"))) (clobber (reg:CC FLAGS_REG))] "" diff --git a/gcc/testsuite/gcc.target/i386/pr116096.c b/gcc/testsuite/gcc.target/i386/pr116096.c new file mode 100644 index 00000000000..5ef39805f58 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr116096.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O2 -flive-range-shrinkage -fno-peephole2 -mstackrealign -Wno-psabi" } */ + +typedef char U __attribute__((vector_size (32))); +typedef unsigned V __attribute__((vector_size (32))); +typedef __int128 W __attribute__((vector_size (32))); +U g; + +W baz (); + +static inline U +bar (V x, W y) +{ + y = y | y << (W) x; + return (U)y; +} + +void +foo (W w) +{ + g = g << + bar ((V){baz ()[1], 3, 3, 5, 7}, + (W){w[0], ~(int) 2623676210}) >> + bar ((V){baz ()[1]}, + (W){-w[0], ~(int) 2623676210}); +}