From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4500E3858C52 for ; Fri, 3 Feb 2023 20:29:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4500E3858C52 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675456189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g1EYiXMEXShBOM/h6l49GLBSuMBk05fe9nS58OfiHU8=; b=CaEBiS7BxSe0aTeYNSs8TxYJlHAc47l6tMwxw4c4Z41+6ZUTJQka8/wB/g5waWUk2EeEe5 MIf1aJlVsR1E84AXeCZnbw/PUMzos7TnpFARQ+YBdxAlKrd81gEImyidiiXzE3qS6vQ7T8 VfxLRi7+8D8EWmxc+pgkuDNVNNk4g5A= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-612-NsX_gbZ6MZmEKQm6bCbC_w-1; Fri, 03 Feb 2023 15:29:49 -0500 X-MC-Unique: NsX_gbZ6MZmEKQm6bCbC_w-1 Received: by mail-wm1-f72.google.com with SMTP id k9-20020a05600c1c8900b003dc5dec2ac6so5224945wms.4 for ; Fri, 03 Feb 2023 12:29:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g1EYiXMEXShBOM/h6l49GLBSuMBk05fe9nS58OfiHU8=; b=bkaqb8GOxnJvqnYJSCZMzOfBsF5A8Mcbc9aCKEVC/8rvkMRrQjU+H7XzHdyQUQKGSq MabOevzadTaYon/afWxaeesm3LX6TGa7+wa/0LEiV5Tjo9iu/CiN1wcn4D3K1dwEQUi8 nmJ/N39K91+VEPeXVtsA9GSyLKqKAY0rjIFmvBTJT+Ndc0obxNCHD9OPdf0D2PlvaHN0 Qsy+UpdItNojGQuEQ8bei+5qCopNN1QToygFaUKK2jYuR8Ed7KArfclj7hvlFEuJSA8t m5CziwpxOrNgbyTj31IlaLsjvLbgTXdx+GQDZ5UZLwftTgPoBcoBmWvZs30PN+sN9irv mZ+A== X-Gm-Message-State: AO0yUKUr14P7YbcC0Y1dWsMWGVisrb7Pwb3Xrfk6VrnAP7HuYSPm2Zgo 8lWxKkvuA74nJluOs9N8thLYFDCZzY3/53/m2aM14+q3/eH7v/CwlDxSrEWslA3vuwwHha85Chf YZhBJ9IRq3ePayLCMqQ== X-Received: by 2002:a05:600c:468a:b0:3db:1637:e415 with SMTP id p10-20020a05600c468a00b003db1637e415mr10581375wmo.22.1675456187824; Fri, 03 Feb 2023 12:29:47 -0800 (PST) X-Google-Smtp-Source: AK7set8roIxdwjbZ4YSHAfpZRDzvmwSadi67Qy0f9mAy152UHaNfihtzthUKPfMkQS1hDYxM3cZtMg== X-Received: by 2002:a05:600c:468a:b0:3db:1637:e415 with SMTP id p10-20020a05600c468a00b003db1637e415mr10581362wmo.22.1675456187581; Fri, 03 Feb 2023 12:29:47 -0800 (PST) Received: from [192.168.1.201] ([139.47.42.170]) by smtp.gmail.com with ESMTPSA id k10-20020a5d6e8a000000b002bdda9856b5sm2793812wrz.50.2023.02.03.12.29.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Feb 2023 12:29:47 -0800 (PST) Message-ID: <2a23c60c-c8ef-a1fd-e7d3-c2ee63f35338@redhat.com> Date: Fri, 3 Feb 2023 21:29:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH] range-op: Handle op?.undefined_p () in op[12]_range of comparisons [PR108647] To: Jakub Jelinek , Andrew MacLeod Cc: gcc-patches@gcc.gnu.org References: From: Aldy Hernandez In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: LGTM On 2/3/23 19:59, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, we ICE because lhs is singleton [0, 0] > or [1, 1] but op2 (or in other cases op1) is undefined and op?.*_bound () > ICEs on those because there are no pairs for UNDEFINED. > > The following patch makes us set r to varying or return false in those > cases. > > Included is a version of the patch I've bootstrapped/regtested successfully > on x86_64-linux and i686-linux, attached is a slight modification more > consistent with the range-op-float.cc patch. > > Ok for trunk (and which one)? > > 2023-02-03 Jakub Jelinek > > PR tree-optimization/108647 > * range-op.cc (operator_equal::op1_range, > operator_not_equal::op1_range): Don't test op2 bound > equality if op2.undefined_p (), instead set_varying. > (operator_lt::op1_range, operator_le::op1_range, > operator_gt::op1_range, operator_ge::op1_range): Return false if > op2.undefined_p (). > (operator_lt::op2_range, operator_le::op2_range, > operator_gt::op2_range, operator_ge::op2_range): Return false if > op1.undefined_p (). > > * g++.dg/torture/pr108647.C: New test. > > --- gcc/range-op.cc.jj 2023-02-03 10:51:40.699003658 +0100 > +++ gcc/range-op.cc 2023-02-03 17:26:02.204429931 +0100 > @@ -642,7 +642,8 @@ operator_equal::op1_range (irange &r, tr > case BRS_FALSE: > // If the result is false, the only time we know anything is > // if OP2 is a constant. > - if (wi::eq_p (op2.lower_bound(), op2.upper_bound())) > + if (!op2.undefined_p () > + && wi::eq_p (op2.lower_bound(), op2.upper_bound())) > { > r = op2; > r.invert (); > @@ -755,7 +756,8 @@ operator_not_equal::op1_range (irange &r > case BRS_TRUE: > // If the result is true, the only time we know anything is if > // OP2 is a constant. > - if (wi::eq_p (op2.lower_bound(), op2.upper_bound())) > + if (!op2.undefined_p () > + && wi::eq_p (op2.lower_bound(), op2.upper_bound())) > { > r = op2; > r.invert (); > @@ -920,6 +922,9 @@ operator_lt::op1_range (irange &r, tree > const irange &op2, > relation_trio) const > { > + if (op2.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -942,6 +947,9 @@ operator_lt::op2_range (irange &r, tree > const irange &op1, > relation_trio) const > { > + if (op1.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1031,6 +1039,9 @@ operator_le::op1_range (irange &r, tree > const irange &op2, > relation_trio) const > { > + if (op2.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1053,6 +1064,9 @@ operator_le::op2_range (irange &r, tree > const irange &op1, > relation_trio) const > { > + if (op1.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1141,6 +1155,9 @@ operator_gt::op1_range (irange &r, tree > const irange &lhs, const irange &op2, > relation_trio) const > { > + if (op2.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1163,6 +1180,9 @@ operator_gt::op2_range (irange &r, tree > const irange &op1, > relation_trio) const > { > + if (op1.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1252,6 +1272,9 @@ operator_ge::op1_range (irange &r, tree > const irange &op2, > relation_trio) const > { > + if (op2.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > @@ -1274,6 +1297,9 @@ operator_ge::op2_range (irange &r, tree > const irange &op1, > relation_trio) const > { > + if (op1.undefined_p ()) > + return false; > + > switch (get_bool_state (r, lhs, type)) > { > case BRS_TRUE: > --- gcc/testsuite/g++.dg/torture/pr108647.C.jj 2023-02-03 16:36:18.347255058 +0100 > +++ gcc/testsuite/g++.dg/torture/pr108647.C 2023-02-03 16:32:16.338811259 +0100 > @@ -0,0 +1,25 @@ > +// PR tree-optimization/108647 > +// { dg-do compile } > + > +bool a; > +int b, c; > + > +inline const bool & > +foo (bool &e, const bool &f) > +{ > + return f < e ? f : e; > +} > + > +void > +bar (signed char e, bool *f, bool *h, bool *g) > +{ > + for (;;) > + if (g) > + for (signed char j = 0; j < 6; > + j += ((f[0] & c ? g[0] : int(0 >= e)) > + ? 0 : foo (g[0], g[0] > h[0]) + 1)) > + { > + a = 0; > + b = 0; > + } > +} > > Jakub