From patchwork Mon Jun 26 14:26:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 1799976 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=W/NIOQg8; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QqVY92sXZz20XS for ; Tue, 27 Jun 2023 00:27:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 47DBC385841D for ; Mon, 26 Jun 2023 14:27:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47DBC385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687789643; bh=PY11dFGCB7xuKBjQD0vKKdyoGvWVC1wHyOsei8DAVmU=; h=Date:Cc:To:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=W/NIOQg8vEfmV4lkTa+8HprHJCGjtBeT4ROMV4G8PFqwfDRCarb/H7mlnU3VErFhR jazti4Ho5NlVm3e4qycMuMz3B0WgBtaJrGCig5HIbZiXW56sxK+dOnm9uQ2bCpbUpv rVE/v6oR3LKSLoJiIeFporGceZeUJRqkfF6Om2xs= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 7E4FF3858D1E for ; Mon, 26 Jun 2023 14:27:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E4FF3858D1E Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3112c11fdc9so2860918f8f.3 for ; Mon, 26 Jun 2023 07:27:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687789621; x=1690381621; h=content-transfer-encoding:subject:from:to:content-language:cc :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=PY11dFGCB7xuKBjQD0vKKdyoGvWVC1wHyOsei8DAVmU=; b=Tc5SWCdZDsN/JGVT5q8Lh47nWk4qXfPM9Ig5/+jKu/dcX0/f58KmYjF1iHXSPBICC/ LgsQ6Ib/Q5l2U60IYMGhbya1gZyGZnFKOprBzdqmgc1NyCg78HUqdsCydHJ2KjvGJ5YY Mel5O2GunniObpsuwGitWAquwlou+C3bSIH9FgKAtYDBEY9JCQXSBdkVlnKrtyh0s/jt Hj7MUN/+fUuiZiEyvwiyG2MtAukryRb4kiICkkQRa9ta813INicp9v2MrToSD+H1ElLy Q1UC7rI80SDKzAeuNvu231LmLLZhQexdUoRVW221QzprZFqvniaFyRGPri6WcIqnPf4z nGug== X-Gm-Message-State: AC+VfDydnWxV/O+O7HKhckWGthjyFvZXfyhFW6knuffFHtnRiAEGziUD eZIB6RW67okb6QUoZ8caWJxy09dScj4= X-Google-Smtp-Source: ACHHUZ43P6xOwxtMbTf9fT/SAHeZoI8zqyfIRMCH/qAi4yGmFVXb6bjmP8O6ne/fsgKEvQz88LxT/w== X-Received: by 2002:a5d:4641:0:b0:313:f463:9d40 with SMTP id j1-20020a5d4641000000b00313f4639d40mr1447018wrs.65.1687789620595; Mon, 26 Jun 2023 07:27:00 -0700 (PDT) Received: from [192.168.1.23] (ip-046-005-130-086.um12.pools.vodafone-ip.de. [46.5.130.86]) by smtp.gmail.com with ESMTPSA id r2-20020a056000014200b00312793cc763sm7527563wrx.15.2023.06.26.07.26.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jun 2023 07:26:59 -0700 (PDT) Message-ID: <3fc809a1-6667-daca-e95a-b0a58825e16f@gmail.com> Date: Mon, 26 Jun 2023 16:26:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Cc: rdapp.gcc@gmail.com, Richard Biener , Tamar.Christina@arm.com Content-Language: en-US To: gcc-patches Subject: [PATCH] match.pd: Use element_mode instead of TYPE_MODE. X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Robin Dapp via Gcc-patches From: Robin Dapp Reply-To: Robin Dapp Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch changes TYPE_MODE into element_mode in a match.pd simplification. As the simplification can be called with vector types real_can_shorten_arithmetic would ICE in REAL_MODE_FORMAT which expects a scalar mode. Therefore, use element_mode instead of TYPE_MODE. Additionally, check if the target supports the resulting operation in the new mode. One target that supports e.g. a float addition but not a _Float16 addition is the RISC-V vector Float16 extension Zvfhmin. Bootstrap on x86_64 succeeded, testsuite is currently running. Is this OK if the testsuite is clean? Regards Robin gcc/ChangeLog: * match.pd: Use element_mode and check if target supports operation with new type. --- gcc/match.pd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 33ccda3e7b6..4a200f221f6 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7454,10 +7454,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) values representable in the TYPE to be within the range of normal values of ITYPE. */ (if (element_precision (newtype) < element_precision (itype) + && target_supports_op_p (newtype, op, optab_default) && (flag_unsafe_math_optimizations || (element_precision (newtype) == element_precision (type) - && real_can_shorten_arithmetic (TYPE_MODE (itype), - TYPE_MODE (type)) + && real_can_shorten_arithmetic (element_mode (itype), + element_mode (type)) && !excess_precision_type (newtype))) && !types_match (itype, newtype)) (convert:type (op (convert:newtype @1)