From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-99bcf2de59cso230233166b.0 for ; Fri, 08 Sep 2023 02:01:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694163707; x=1694768507; darn=gcc.gnu.org; h=content-transfer-encoding:subject:from:to:content-language:cc :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=9jwwJ5+Ik7S+T/7SrfhzmWW8MHL943KWPdhKat/+e3I=; b=C4jdnCOBwzVCvWE5CjoUeJXiWJfkW7tLWhi4Bn4qEh+20USJmKLzgy+n590AEclOrc 7KxNuC9qW5xwgjZTfPVttqmOwVr8PKUwPBxw0m6IrPYHRexAdpXL+wVBvONhxYtIlZTS lhLzx+MmYo//Ndx2iW8eXHq5kZ21Bqab+s65wenoLLG8lzXzHkNl7GbNnFoOW6rVWFvz 6zAshLpJuVsMTNzUhhIgBiyzHxGc3a+50c0tqhXD2/HtuNLPkzLrSvG66SX+svtLgvCZ T+m/rWVComE3gbR8BqCCw7leLj//aXnhoDPjG3thjoeV7VvjuxlCG9n+rmQraLfWbYvW NhUg== 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 Cc: rdapp.gcc@gmail.com, "richard.sandiford" Content-Language: en-US To: gcc-patches From: Robin Dapp Subject: [PATCH] gimple-match: Do not try UNCOND optimization with COND_LEN. Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 List-Id: 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)) -- 2.41.0