From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 5A1FE38485AB for ; Wed, 1 Jun 2022 14:07:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A1FE38485AB Received: by mail-pl1-x635.google.com with SMTP id h1so1891951plf.11 for ; Wed, 01 Jun 2022 07:07:09 -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=q02WHPXX7iPVJS4rf+jsLM+vzjc2jV4i1fqU4JWremw=; b=15ds9cTx6bY2SVimkvUjYttaQOj5uJC/dG1R0eIxF3FlchAgXx4L1EFVrjvlbpqXqT YB016bFTvJOKpwSgfnPyi5ZpDTQd4esNxdqQYYvWXDTmGxPKUXzfeOHTEJ5FW19HScWX QRx3+/2ar4S1jicrBkqafiFPLIDVQuwd69SbNP/BFubSJPDDGI90xnOheulV0WyOElrq I0LhdqOJ5u/UPN93TmzCru/9R1Hjj0TluzoaYp274c8l85az+0n7mWuYsvRtO4JKfSeS LewYPWN/UlVv7onU4864nTabWb3gltmlxefJkho/pEaszoIXhugUZKgR0YTbvSvss2gT Lz+A== X-Gm-Message-State: AOAM533v7PkgvR4H8PDKbPuibZrOSBWEdQ/bf3B8/6UujX05vlJIxdvG WYSpCEElLOYB9UtXW7Rb9KV8+vuTubDRJg== X-Google-Smtp-Source: ABdhPJwh64rFK4xcjnSSlqCdZjEtg/PdG/MVjL3JkXE6VEFAfyldjgpoWHNZD+QNyGkhTVBnAeA3+g== X-Received: by 2002:a17:902:e5c9:b0:166:34ff:72a3 with SMTP id u9-20020a170902e5c900b0016634ff72a3mr825328plf.80.1654092428010; Wed, 01 Jun 2022 07:07:08 -0700 (PDT) Received: from [172.31.0.204] (c-73-63-24-84.hsd1.ut.comcast.net. [73.63.24.84]) by smtp.gmail.com with ESMTPSA id k14-20020aa7998e000000b0050dc7628137sm1602440pfh.17.2022.06.01.07.07.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Jun 2022 07:07:07 -0700 (PDT) Message-ID: Date: Wed, 1 Jun 2022 08:07:06 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] match.pd: Optimize __builtin_mul_overflow_p (x, cst, (utype)0) to x > ~(utype)0 / cst [PR30314] 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: 7bit X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, 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, 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-List-Received-Date: Wed, 01 Jun 2022 14:07:10 -0000 On 6/1/2022 7:55 AM, Jakub Jelinek via Gcc-patches wrote: > Hi! > > A comparison with a constant is most likely always faster than > .MUL_OVERFLOW from which we only check whether it overflowed and not the > multiplication result, and even if not, it is simpler operation on GIMPLE > and even if a target exists where such multiplications with overflow checking > are cheaper than comparisons, because comparisons are so much more common > than overflow checking multiplications, it would be nice if it simply > arranged for comparisons to be emitted like those multiplications on its > own... > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2022-06-01 Jakub Jelinek > > PR middle-end/30314 > * match.pd (__builtin_mul_overflow_p (x, cst, (utype) 0) -> > x > ~(utype)0 / cst): New simplification. > > * gcc.dg/tree-ssa/pr30314.c: New test. OK jeff