From patchwork Mon Jul 12 23:42:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1504283 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GP0gZ3BnLz9sRK for ; Tue, 13 Jul 2021 09:42:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 671143896C23 for ; Mon, 12 Jul 2021 23:42:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 671143896C23 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1626133360; bh=20upZn3ZCywp5dt65B3KAj1xyRbD6Kt6+ZkxMyriaB8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=xHN/I2E5iedNu4qUwZe/5vhhTDJKwtWueZj27YHf5Cq+W1lLvTt+TKk+n5pgiMcjJ 7/Wi7uxkmYb8moJeeYgJjO6t8ndnPRfUpQr4ZFqZSjB6MyZLynIuK6Shom5XFM8IYO I9jX8pCk0YvupdVVjhsmFNv21pUHVeeKEbpeSsco= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id A48203861C5A for ; Mon, 12 Jul 2021 23:42:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A48203861C5A Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-433-p3pUvXdAMBW8S9KjGp0LMA-1; Mon, 12 Jul 2021 19:42:17 -0400 X-MC-Unique: p3pUvXdAMBW8S9KjGp0LMA-1 Received: by mail-qk1-f198.google.com with SMTP id 81-20020a370b540000b02903b854c43335so4700777qkl.21 for ; Mon, 12 Jul 2021 16:42:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language; bh=20upZn3ZCywp5dt65B3KAj1xyRbD6Kt6+ZkxMyriaB8=; b=m+ILVTevAy02W+F1wDb9AI78+6dT/pvUx0sKOJVXjnzdFUwQBPEqDp43MM7KPqfH/M sOHR6SGk/yUhBgJubkGJxXhWcuacUCYlYpAFG6WZtzTS5R4xpDdSZ/7bQ4CRjcPn6fnm Jwf3XMus9c/ee1Dva1K2xJGKMhuUO+OpJXC9+1RErkjgKGRHqgXqkuyTohbnYRrafZyQ B6SUmWpgt+Gb460wcYolOGZiRg/4XUDj9EAWaWwhsAwOF6CSkT4/wDbiBIuiLQdyj61P tCaI8dry0DtMIHh8yqKWl5TGucbhoJ4bVmDmYI7E5HFv372HblEIS9kQKPS4ADKFwE2b OA3Q== X-Gm-Message-State: AOAM532fyQQ2ESMbzyEKl3JGGk6/ieqcNn/bR40lvTVitABYLJRJfa4D fiVUmVZyQlLUFHucsFYjEaGAn4XgM7M0OYRBZCGUnWBTNJszUSq7DuMkOHwUhH8yWmie1tJQFFA rEN5JR5bpwzfX+i17cg== X-Received: by 2002:ac8:531a:: with SMTP id t26mr1331714qtn.207.1626133337091; Mon, 12 Jul 2021 16:42:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5El8GksMV/fDEqnXh7mqKLA2zOxTKryb4Leo9qWFtJtMQrqDitxT08A3t0qWKWqnxk7iiBA== X-Received: by 2002:ac8:531a:: with SMTP id t26mr1331701qtn.207.1626133336876; Mon, 12 Jul 2021 16:42:16 -0700 (PDT) Received: from [192.168.0.102] ([104.219.122.163]) by smtp.gmail.com with ESMTPSA id s6sm7078766qkc.125.2021.07.12.16.42.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jul 2021 16:42:16 -0700 (PDT) To: gcc-patches Subject: [COMMITTED] Add relation processing to ubsan builtins, and EVRP equality. Message-ID: Date: Mon, 12 Jul 2021 19:42:15 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Ubsan builtins use the plus,minus and multiply operations under the covers, but they are not relation aware.  This patch queries for a relation between the 2 operands and passes that on to range-ops. This resolves gcc.dg/pr97505.c when operating in ranger-only mode, and with that, ranger-only mode runs the gcc testsuite clean on x86_64-pc-linux-gnu. If there are no objections, I'd like to change the default mode to ranger only, and see if something shows up on any other architectures, or in any other places.  We can easily switch back if need be. I'll keep running things in hybrid mode locally to ensure we don't start losing parity with legacy EVRP.  Does this seem reasonable? Andrew commit 9693ecdf7ed5dde9618d06560697ff8ee5e1e6b7 Author: Andrew MacLeod Date: Mon Jul 12 14:38:42 2021 -0400 Add relation processing to ubsan builtins. Ubsan builtins call the plus/minus/multiple fold routines, but did not use any relation information between the 2 operands that is available. query and pass any relations. This resolves gcc.dg/pr97505.c when operating in ranger-only mode. * gimple-range-fold.cc (fold_using_range::range_of_builtin_ubsan_call): Query relation between the 2 operands and use it. diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 1fa4ace32b9..eff5d1f89f2 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -825,12 +825,14 @@ fold_using_range::range_of_builtin_ubsan_call (irange &r, gcall *call, tree arg1 = gimple_call_arg (call, 1); src.get_operand (ir0, arg0); src.get_operand (ir1, arg1); + // Check for any relation between arg0 and arg1. + relation_kind relation = src.query_relation (arg0, arg1); bool saved_flag_wrapv = flag_wrapv; // Pretend the arithmetic is wrapping. If there is any overflow, // we'll complain, but will actually do wrapping operation. flag_wrapv = 1; - op->fold_range (r, type, ir0, ir1); + op->fold_range (r, type, ir0, ir1, relation); flag_wrapv = saved_flag_wrapv; // If for both arguments vrp_valueize returned non-NULL, this should