From patchwork Fri Feb 23 12:58:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1903272 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=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=U2bhTYFW; 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 4Th9B30L0pz23l1 for ; Sat, 24 Feb 2024 00:01:15 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 048B33858436 for ; Fri, 23 Feb 2024 13:01:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id CB60B385840C for ; Fri, 23 Feb 2024 13:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB60B385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=baylibre.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CB60B385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::333 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708693251; cv=none; b=Z1+uwCcTWSo3yyjM/v1pX57UD5I0Z+QA9R3YAvsVeiIGZkvvXvWDBv9+x2lFlzxBzIPNm8MxR4ssvFFlPVakcx2GbihG9qeGWGPx/eSZBh7OCEkdYpmQO6GU+xuix/Mf7vzmFsl0C6W75odF5Vq+Q21d7zZg9VPE3LYGQp93hpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708693251; c=relaxed/simple; bh=p4RdovFISyDBO85bUSRi57TPky5h9aF4wEqpo37qnHs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=B18AKgKB/rNngPl1ZO64eVr0jnt7CbPMVTxjI05qxrk8ebgGzxaDZ1DEjKM9oJAQnCHg4PI/0vRBk8rcsnXBR8gEHqtwCJLViXbGPJvGdCydZ8Hmjo7qFAJ762+YvXtB4fR4in1T79WguhmYJtvUyaAq2Puqwm+A9ytRO4F4N1s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-412897a2f9eso5147725e9.1 for ; Fri, 23 Feb 2024 05:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1708693246; x=1709298046; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=M9MWeYnvJ1eZW0zWYpMfIcJonwSYPC+gcwhHLYAg8P4=; b=U2bhTYFWMot6vN+haCW7u6wfMUHSa39dvNJh7vS0ub+HnPK2e75ifrJmoPH5/EKEZQ tE1gD/aSTNYr6uCqM1Mw26qrLmSZzt+GnKbrqHVcRZ3PqQmvF8ohxY8jKts+oNKWnuqn pLTtBazCnX1N/Wi8C4Z7YN1Qyv88pjg0Kva0f5qturvQEoWgJ74rgQUYx13spfn3Abmd DC7+SRDw8bSuvwCmu7Xxt5mCWNRqVDP4SvUthZfi5WZ4a0Evz8RsCnhYmGQKmas4nvnv 9f6UptKM6ixZfiq4AWmxNeWrRGmlBAuaQAjRtKX0BtKI9vFaFqWEJp/Bml2QVCEsinKO yGYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708693246; x=1709298046; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=M9MWeYnvJ1eZW0zWYpMfIcJonwSYPC+gcwhHLYAg8P4=; b=rxxcy1/z2C1TUArtlssoDUsFSwLb9Hk+Yz+HMhvLpL/WlZexiqwEAlSM7rHTxfLGm7 oIUJKEjXZk2R3u2zmEw+6fH0V8kBbiEZf3C/IXLPwd6Yr89m9TRcNrR+ZhyzFeaJRM0R gWi4XHq5niznFR7fq4GQxEW58q9StVzlFmsUzk8FGWs8CkdRBWWGVUUlWHM3rYbphccm 1KUeTjaQdT59J28CHdnimpiDWcGV58JTNTPigLcjJbPblYR7JBLiUvwpX7K3bRiDhMv3 oFHc7R+zEVzd1Y/ccNw+z+cAlfw50nWFTUkEYJrnYulIft4KVm6SX0u0ClzKlY0WGPZe E9Hw== X-Gm-Message-State: AOJu0Yxa7E019W9ynCIGvNKWvrvdFQfXjXyGCajmRdQMwJVAdu5Vkuk0 Te/8AFXflM+kKCZxTDhzN7DQFbUQ5Ywb4p5WABk18sWFaENs8KQ91D8+Uu6uR1BqSh1hHsTMJIr IopQ= X-Google-Smtp-Source: AGHT+IGVyCcpHn9nJNHeohHuMpncUzi/Hf49o+8xuR0BFaT8FhMYRcNRiae8zb+NfbHxx6OKsSJY7Q== X-Received: by 2002:a05:600c:3b16:b0:411:b2f4:16e9 with SMTP id m22-20020a05600c3b1600b00411b2f416e9mr5044138wms.14.1708693245855; Fri, 23 Feb 2024 05:00:45 -0800 (PST) Received: from chuck.baylibre (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id d8-20020a05600c34c800b00412961173e4sm1599855wmq.25.2024.02.23.05.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 05:00:45 -0800 (PST) From: Andrew Stubbs To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de Subject: [PATCH] vect: Fix integer overflow calculating mask Date: Fri, 23 Feb 2024 12:58:53 +0000 Message-ID: <20240223125853.752639-1-ams@baylibre.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 This is a follow-up to the previous patch to ensure that integer vector bit-masks do not have excess bits set. It fixes a bug, observed on amdgcn, in which the mask could be incorrectly set to zero, resulting in wrong-code. The mask was broken when nunits==32. The patched version will probably be broken for nunits==64, but I don't think any current targets have masks with more than 64 bits. OK for mainline? Andrew gcc/ChangeLog: * expr.cc (store_constructor): Use 64-bit shifts. --- gcc/expr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index e238811110e..90de5decee3 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -7879,7 +7879,7 @@ store_constructor (tree exp, rtx target, int cleared, poly_int64 size, auto nunits = TYPE_VECTOR_SUBPARTS (type).to_constant (); if (maybe_ne (GET_MODE_PRECISION (mode), nunits)) tmp = expand_binop (mode, and_optab, tmp, - GEN_INT ((1 << nunits) - 1), target, + GEN_INT ((1UL << nunits) - 1), target, true, OPTAB_WIDEN); if (tmp != target) emit_move_insn (target, tmp);