From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 16F0D3857C58 for ; Sat, 30 Jul 2022 19:57:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 16F0D3857C58 Received: by mail-pg1-x52f.google.com with SMTP id q16so6532602pgq.6 for ; Sat, 30 Jul 2022 12:57:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=/Gs5gxmanzhAYxPI4lrGmKixGkE1lFmdetqSF7+6UuQ=; b=JlqjyZsW/r48LPplnxfCvcP28JS0uD8FLxlNK4eLmV9Eee4cpZObCIQQb1wj+mqDqB BNuJvhTs1zDiIz3D1mPIKdjtIGqhg4VglYhcsZOwKRnEeln84lUWBUKjxtgQVa4Q1Ifc 6LOb8pYP6V1TY8eajtXF+bBo6CwYM5QcssNIkuKUV2gm0mKyDYPKhKqI9hODQhUrG4L+ wKNgquOPuEBkOkBAQLW76PSCcabFdv+GHmbMzLZ7tOnBO/qFgWREVU/ykZbl+S8E0I8g IUrspRP85RwrhwYCXMDhSctKuPc6tbHi0hUkoJPvWbH90G9JGUBW3qAuy2HwyOSsuWP3 MpAA== X-Gm-Message-State: AJIora8YtPHsXm8qU8xTVZq2Qx5/uUP78d3PTfPHqmP/qP3Mg4f3tZh3 0hTqW3T4pUqeIs6orhj3dRNf+QHpXFA= X-Google-Smtp-Source: AGRyM1vOmmFlBsSj3Cpy/nHNkefPxlE7Yu8UXkrvXC1ABwtt2OdR+9Bu04Q0wsCalJZYKpAPbKj22Q== X-Received: by 2002:a05:6a00:27a1:b0:52b:a5f:6ae6 with SMTP id bd33-20020a056a0027a100b0052b0a5f6ae6mr9193411pfb.50.1659211040323; Sat, 30 Jul 2022 12:57:20 -0700 (PDT) Received: from [172.31.0.204] (c-73-98-188-51.hsd1.ut.comcast.net. [73.98.188.51]) by smtp.gmail.com with ESMTPSA id 73-20020a63064c000000b00419cde333eesm4738323pgg.64.2022.07.30.12.57.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 30 Jul 2022 12:57:19 -0700 (PDT) Message-ID: <9e9b7ec5-4c10-115d-8b6d-a7a07bfd72be@gmail.com> Date: Sat, 30 Jul 2022 13:57:18 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2] cselib: add function to check if SET is redundant [PR106187] Content-Language: en-US To: gcc-patches@gcc.gnu.org References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, NICE_REPLY_A, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2022 19:57:25 -0000 On 7/29/2022 7:52 AM, Richard Earnshaw via Gcc-patches wrote: > A SET operation that writes memory may have the same value as an > earlier store but if the alias sets of the new and earlier store do > not conflict then the set is not truly redundant.  This can happen, > for example, if objects of different types share a stack slot. > > To fix this we define a new function in cselib that first checks for > equality and if that is successful then finds the earlier store in the > value history and checks the alias sets. > > The routine is used in two places elsewhere in the compiler. Firstly > in cfgcleanup and secondly in postreload. > > gcc/ChangeLog: >     * alias.h (mems_same_for_tbaa_p): Declare. >     * alias.cc (mems_same_for_tbaa_p): New function. >     * dse.cc (record_store): Use it instead of open-coding >     alias check. >     * cselib.h (cselib_redundant_set_p): Declare. >     * cselib.cc: Include alias.h >     (cselib_redundant_set_p): New function. >     * cfgcleanup.cc: (mark_effect): Use cselib_redundant_set_p instead >     of rtx_equal_for_cselib_p. >     * postreload.c (reload_cse_simplify): Use cselib_redundant_set_p. >     (reload_cse_noop_set_p): Delete. Seems quite reasonable.   The only question I would have would be whether or not you considered including the aliasing info into the hashing used by cselib.  You'd probably still need the bulk of this patch as well since we could presumably still get a hash conflict with two stores of the same value to the same location, but with different alias sets (it's just much less likely), so perhaps it doesn't really buy us anything. Ideally this would include a testcase.  You might be able to turn that non-executawble reduced case into something useful by scanning the post-reload dumps. Jeff