From patchwork Wed Jun 28 15:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 113964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9028124vqr; Wed, 28 Jun 2023 08:54:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66EzMOj68o2QC6zXOqTt6g4+NvQ6GtgxV+vMwA5lmTqMbAVYgPNCKk0tuaL9fnJFgHMuJj X-Received: by 2002:a05:6402:5210:b0:51a:41fd:9732 with SMTP id s16-20020a056402521000b0051a41fd9732mr2678858edd.11.1687967677161; Wed, 28 Jun 2023 08:54:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687967677; cv=none; d=google.com; s=arc-20160816; b=ncDmb5gPvSIyEeGWETZrCSQVwzwdJ6fHl95SMu09Y7d+o4cXrHIY3F1o7/X1DYoAki MkOTJUBH3XXA9wssfHLAzhTMlHXu9DcV5r5oaYZ9prnRzidSMySg28S+FgTkoW57NHZv M0jQ6fJDxzEZyLCuXu2CxDZzh9hy+yxsZtzfJiKZQDMp766WtPfgaUL6jgNMNRTqk231 Qc0yVjj+RTwdOLWWb37lOPTiuUpAgOM2n0XNauluy5JcFo7ZV+KMRZu137erxcbQO5ib yrygHUjEaiLWbyAZe06mk/gsYfu2vGzi6bke9aaR7OpHjaojvRuHeOBgBaJ1nvQbgeju RrcQ== 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=ClklFrs1kYxP8rGW+Z/fBjbU5jyKrLBx8PTqQmx0ldQ=; fh=D2tRalIjW6KCgVuqwFHStdMb9uqe8HSQc2WEvRJ6uLE=; b=j4V/U2KtkAQ7V+YIT8QV4zHilxXEKyZs0B7l8iH1crnoOJfdkD/SyY5Ml8VUypOCCt bsLKWG5254n7zn4dYzzcn2OlOjzpfcPtuc6mEBfCMEytgDV2vOBfpJLFgqsN7aw16BLR NfxYhinRBBFiOJeZfLZ0yCGy1FJdomszyXkNi0opzhUYb1z4RKpP9stZx61wNkuQ2rYS nP7UMS/QLPbFnMngGEc0+60A2R41FBAnNrNdnGYZLLFElhw3we1ONXBJdQgvbZvOh/a6 fnByYGC5YHvrgL7CpWJLl1gGx0pehoOqSf+zc9qAE6kJVDZ2idNwD+LFJ2yarWfdrdfF gOFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fUI2LD4Y; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s7-20020a056402164700b0051db73ddb6csi1472153edx.649.2023.06.28.08.54.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Jun 2023 08:54:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fUI2LD4Y; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 1EEFD3858402 for ; Wed, 28 Jun 2023 15:54:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EEFD3858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687967676; bh=ClklFrs1kYxP8rGW+Z/fBjbU5jyKrLBx8PTqQmx0ldQ=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=fUI2LD4YRvLyGa/QNv/wA/rTEqNl2o/AybT66PoHhuuKC4KzZiRysGv/nPFj/8mvC cDqHTBPnXrai966JYYUhknM4UpxBMgsnqDUZOukPOtgUV0UQSg/RSzm4j5P/3KLuEo MErdmpJHBpkYG91YObpOnSBZRVeKU32hl7GxX6Fk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) by sourceware.org (Postfix) with ESMTPS id 75AD43858C2C for ; Wed, 28 Jun 2023 15:53:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75AD43858C2C Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4QrmMx0vc1z9sWJ; Wed, 28 Jun 2023 17:53:49 +0200 (CEST) To: gcc-patches@gcc.gnu.org Cc: Iain Buclaw Subject: [committed] d: Fix d_signed_or_unsigned_type is invoked for vector types (PR110193) Date: Wed, 28 Jun 2023 17:53:47 +0200 Message-Id: <20230628155347.2144291-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4QrmMx0vc1z9sWJ X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw 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?1769962395309048001?= X-GMAIL-MSGID: =?utf-8?q?1769962395309048001?= Hi, The function being changed in this patch can be invoked on VECTOR_TYPE, but the implementation assumes it works on integer types only. To fix, added a check whether the type passed is any `__vector(T)' or non-integral type, and return early by calling `signed_or_unsigned_type_for()' instead. Problem was found by instrumenting TYPE_PRECISION and ICEing when applied on VECTOR_TYPEs. Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed to mainline. Regards, Iain. --- PR d/110193 gcc/d/ChangeLog: * types.cc (d_signed_or_unsigned_type): Handle being called with any vector or non-integral type. --- gcc/d/types.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/d/types.cc b/gcc/d/types.cc index a4c05bfb75f..bdf07f83d4b 100644 --- a/gcc/d/types.cc +++ b/gcc/d/types.cc @@ -49,8 +49,8 @@ along with GCC; see the file COPYING3. If not see static tree d_signed_or_unsigned_type (int unsignedp, tree type) { - if (TYPE_UNSIGNED (type) == (unsigned) unsignedp) - return type; + if (VECTOR_TYPE_P (type) || !ANY_INTEGRAL_TYPE_P (type)) + return signed_or_unsigned_type_for (unsignedp, type); if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type)) return unsignedp ? d_ucent_type : d_cent_type;