From patchwork Mon Aug 8 20:44:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1664696 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=l83yFqiu; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M1pBm6dfyz9sFs for ; Tue, 9 Aug 2022 06:46:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A74B4385AC09 for ; Mon, 8 Aug 2022 20:46:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A74B4385AC09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659991561; bh=nLVVKcJXtLKzMd/j/N++HCYF5dCwoEQLVnxj5vSzRUk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=l83yFqiuDVF6I8sLUKpMVdghP/oA1ivBcRXsxWt7Yb4snxjbvQOu+vlIxwV6K1qPn OZk+tjncm4fO7RZ4YDFpEQst7i1a69ASL0MPMxYG3JZmJnC6Zvq2MteQgMrA4XShv5 sNWFTschDHKkXyCdXmwa/a4H/cv23kibxjrE19/U= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 33E1D385AC1B for ; Mon, 8 Aug 2022 20:45:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33E1D385AC1B Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-478-Nm4JYK1_Pi-4zhb7rrFBzQ-1; Mon, 08 Aug 2022 16:44:50 -0400 X-MC-Unique: Nm4JYK1_Pi-4zhb7rrFBzQ-1 Received: by mail-il1-f199.google.com with SMTP id a17-20020a056e0208b100b002dc52b51d98so7294662ilt.0 for ; Mon, 08 Aug 2022 13:44:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc; bh=vVQxzCPS+Xz3zszGn53ssGa+mKvkXYIWHycnpOCwWqI=; b=uKg4ftkZX9bD4/86GvInQ6cqiyt2qGpBoTlYz5esVA6v8LGEsuu+QQKLZOoSMRFAIh Zrm8CFQWi1yZ0UQdGWUXXA2zfrFHGaAwSCkP7U/1OkyeX2YzkvKvFmbXZw1B+X3Ek+nz aaz8Mvcm3MAa38SOTEGhnx/lwg0kl4Vl8YIAtTGaZHyhpz2Quz8Ntt6b9z8kuDKcq7bs JoHXQuXTy+QGuD11euv4hFEyB7CZQXyDOJm2CPkAoZBcVuemvEUZaUW4s/Jun8DZp1ct 1PV9gEkYlIvqXVqk8Umk3BX2VpJcBcXXXdtOXavjotMpyqp99xU2oGewEAT7h2rIIRPF e5tQ== X-Gm-Message-State: ACgBeo3RBNvmsAG0UvAV6r/w7EISC/mKNXjRLSG63YPc+ZTdWqmaNPvo gSAq4Dj0MEcPtFv8jF45o9tW2+M60PYqQSZxmmOlCCI/7fnri1HU9hU4uTeqF/4mndODACjKher jtefKgRq0AxDVw6e/RqlyVVIvfqwVfqHdOWHrhIucFzJeqQwMP04k1Ktj7dhtp0f5yspZkw== X-Received: by 2002:a02:9522:0:b0:342:7a19:1381 with SMTP id y31-20020a029522000000b003427a191381mr9498052jah.184.1659991476379; Mon, 08 Aug 2022 13:44:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR5ScYDtvVba+cwVVqb45D3vnoIEhRNIovjaqnHdCGzhE3SgmQT6o1kusk9tYWGKmMuNThg8xg== X-Received: by 2002:a02:9522:0:b0:342:7a19:1381 with SMTP id y31-20020a029522000000b003427a191381mr9498047jah.184.1659991476118; Mon, 08 Aug 2022 13:44:36 -0700 (PDT) Received: from [192.168.0.135] ([192.24.49.145]) by smtp.gmail.com with ESMTPSA id s17-20020a056e0210d100b002dd3b25302csm251737ilj.81.2022.08.08.13.44.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Aug 2022 13:44:35 -0700 (PDT) Message-ID: <8b1c215e-263e-b24d-9ab7-5b40c62142d5@redhat.com> Date: Mon, 8 Aug 2022 16:44:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: gcc-patches Subject: [COMMITTED] PR tree-optimization/106556 - Evaluate condition arguments with the correct type. X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-12.7 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_NONE, SPF_HELO_NONE, SPF_NONE, 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-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" when evaluating a COND_EXPR, we need to evaluate both operands. With the recent changes to floating point, we missed that we are accidentally using the LHS range type for the operands.. that was fine when everything was an irange... but no so any more. This patch simply uses the right range type for the temporary ranges. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew commit 6d57764711d3b4441d4d99876d9d3370bdec6284 Author: Andrew MacLeod Date: Mon Aug 8 15:13:51 2022 -0400 Evaluate condition arguments with the correct type. Processing of a cond_expr requires that a range of the correct type for the operands of the cond_expr is passed in. PR tree-optimization/106556 gcc/ * gimple-range-gori.cc (gori_compute::condexpr_adjust): Use the type of the cond_expr operands being evaluted. gcc/testsuite/ * gfortran.dg/pr106556.f90: New. diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc index a43e44c841e..8879e44cba1 100644 --- a/gcc/gimple-range-gori.cc +++ b/gcc/gimple-range-gori.cc @@ -1398,16 +1398,17 @@ gori_compute::condexpr_adjust (vrange &r1, vrange &r2, gimple *, tree cond, } // Now solve for SSA1 or SSA2 if they are in the dependency chain. - Value_Range tmp (type); if (ssa1 && in_chain_p (ssa1, cond_name)) { - if (compute_operand_range (tmp, def_stmt, cond_true, ssa1, src)) - r1.intersect (tmp); + Value_Range tmp1 (TREE_TYPE (ssa1)); + if (compute_operand_range (tmp1, def_stmt, cond_true, ssa1, src)) + r1.intersect (tmp1); } if (ssa2 && in_chain_p (ssa2, cond_name)) { - if (compute_operand_range (tmp, def_stmt, cond_false, ssa2, src)) - r2.intersect (tmp); + Value_Range tmp2 (TREE_TYPE (ssa2)); + if (compute_operand_range (tmp2, def_stmt, cond_false, ssa2, src)) + r2.intersect (tmp2); } if (idx) { diff --git a/gcc/testsuite/gfortran.dg/pr106556.f90 b/gcc/testsuite/gfortran.dg/pr106556.f90 new file mode 100644 index 00000000000..01b89a8eee2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr106556.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! { dg-options "-O1 -fnon-call-exceptions -ftree-loop-if-convert" } + + +program p + real :: a(2) + + a(:) = 1.0 + if (minloc (a, dim = 1).ne.1) STOP 1 +end