From patchwork Fri Sep 8 09:01:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 1831393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=DywYdayM; 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 4Rhqql0C3sz1ygR for ; Fri, 8 Sep 2023 19:02:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3BE13858414 for ; Fri, 8 Sep 2023 09:02:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3BE13858414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694163728; bh=9jwwJ5+Ik7S+T/7SrfhzmWW8MHL943KWPdhKat/+e3I=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=DywYdayMYvmtDM0t8+aVch5l3v1o8asFZRTsHWQFOchkDb4LKtGmE1P8ce7g9eyJ2 zJwo+rT/7ePFwnDa30G8gW/VrJk1xyGO/d1CF9My5dKKhOsxgMwUb1zAoUPepQlYoI 9JDetwYTCjXUADVIYVhq9PusegfIRKGU1axB4x6U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by sourceware.org (Postfix) with ESMTPS id 8FCE63858D1E for ; Fri, 8 Sep 2023 09:01:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8FCE63858D1E Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-99bcf2de59cso230233166b.0 for ; Fri, 08 Sep 2023 02:01:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694163707; x=1694768507; 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=9jwwJ5+Ik7S+T/7SrfhzmWW8MHL943KWPdhKat/+e3I=; b=wwW1PnQ/g2ASzt2rfW+pK7dZGC59BHWUc3qBqghs1vHy0xjHbLDUdjSCDR01A1ntz5 BUqIhv8aFsCOVFxbgXrnUT2NK4FyrTn18zej6UiWRal6vgbwqtDDRBoUzARx9HWQlm+Y +m9cyzg3tJtLAwjVv748lmJdCsA5f5ZCjBEyjb2NB4PY+M21oyX+7vQL3n3WKbC+MGmu n6Nq4AHdCHBog6IDoUnyL55zLJ06uiCaV472lY0SQ0Y9icqHJxGOWqo43P4QAfrcJeS6 i/9f6HaUWRinM0CU7KyfS/YEzT/2BLb8nVqz1PdnQOe68AYCHL0uvYDKu9fj3o5uZH07 ZQ5A== X-Gm-Message-State: AOJu0YyWEK+dSUeNyB/f+jg4r1MYOBQMVwyj4Mi7Hu7pJvBRIjOTD3Ay qaJPa1UPVbptCDgtmhAPxbKeEAZulk3PPA== X-Google-Smtp-Source: AGHT+IGp43LDt/s+90d5KcpFCoKuschZzfKaq90X2bWSdX4fGciRhEGwobP0EtfhOKU2Z09qnq+7qQ== X-Received: by 2002:a17:906:10c9:b0:9a9:fc74:8d50 with SMTP id v9-20020a17090610c900b009a9fc748d50mr768887ejv.66.1694163706686; Fri, 08 Sep 2023 02:01:46 -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 n13-20020a170906b30d00b0099cc36c4681sm731732ejz.157.2023.09.08.02.01.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Sep 2023 02:01:46 -0700 (PDT) Message-ID: <4b77e155-0936-67d6-ab2d-ae7ef49bfde0@gmail.com> Date: Fri, 8 Sep 2023 11:01:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: gcc-patches Subject: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN. X-Spam-Status: No, score=-9.2 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 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: , X-Patchwork-Original-From: Robin Dapp via Gcc-patches From: Robin Dapp Reply-To: Robin Dapp Cc: "richard.sandiford" Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, found in slp-reduc-7.c, this patch prevents optimizing e.g. COND_LEN_ADD ({-1, ... }, a, 0, c, len, bias) unconditionally into just "a". Currently, we assume that COND_LEN operations can be optimized similarly to COND operations. As the length is part of the mask (and usually not compile-time constant), we must not perform any optimization that relies on just the mask being "true". Bootstrap and testsuite are unchanged on aarch64 and x86. Regards Robin gcc/ChangeLog: * gimple-match-exports.cc (maybe_resimplify_conditional_op): Check for length masking. --- gcc/gimple-match-exports.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc index b36027b0bad..73be9f4f4c3 100644 --- a/gcc/gimple-match-exports.cc +++ b/gcc/gimple-match-exports.cc @@ -262,7 +262,8 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op, if (!res_op->cond.cond) return false; - if (!res_op->cond.else_value + if (!res_op->cond.len + && !res_op->cond.else_value && res_op->code.is_tree_code ()) { /* The "else" value doesn't matter. If the "then" value is a @@ -301,9 +302,12 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op, /* If the "then" value is a gimple value and the "else" value matters, create a VEC_COND_EXPR between them, then see if it can be further - simplified. */ + simplified. + Don't do this if we have a COND_LEN_ as that would make us lose the + length masking. */ gimple_match_op new_op; - if (res_op->cond.else_value + if (!res_op->cond.len + && res_op->cond.else_value && VECTOR_TYPE_P (res_op->type) && gimple_simplified_result_is_gimple_val (res_op)) { @@ -314,7 +318,7 @@ maybe_resimplify_conditional_op (gimple_seq *seq, gimple_match_op *res_op, return gimple_resimplify3 (seq, res_op, valueize); } - /* Otherwise try rewriting the operation as an IFN_COND_* call. + /* Otherwise try rewriting the operation as an IFN_COND_(LEN_)* call. Again, this isn't a simplification in itself, since it's what RES_OP already described. */ if (convert_conditional_op (res_op, &new_op))