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.129.124]) by sourceware.org (Postfix) with ESMTPS id 694EF385840C for ; Wed, 1 Dec 2021 18:21:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 694EF385840C Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-ruft1wMhNmaQeDE357hCNw-1; Wed, 01 Dec 2021 13:21:34 -0500 X-MC-Unique: ruft1wMhNmaQeDE357hCNw-1 Received: by mail-qk1-f199.google.com with SMTP id az44-20020a05620a172c00b0046a828b4684so34672268qkb.22 for ; Wed, 01 Dec 2021 10:21:34 -0800 (PST) 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:cc:references:from:in-reply-to :content-transfer-encoding; bh=X9Ec+f9HJii2fl9fdrRzdoSD7EzjEd+3P24LhjJ9fUg=; b=dGQPAshVe7NnhFTPQ4sBjShqwvu+6v4k3hj09ZYNhoBLkUkN41cvRMv8X3rpZwYlK+ YRZWSYWaaSTob0sc4bXht5O3MNVNGJXqeYnybaYpCoBkvJy+NSLfmqyuZkPi2J63ojDL vrG68WKs+YXQL3wuvabV9vV+gXCdYs7wu0gNFsRrvkvGH/ApcQLj1BCpDOWOzqDZtH/a 9yGFUlw5xLG0rtkWQl/D5omV9r7W7NQHV9IYY65kYYM9BUek6MHZMyLV0If9X7cDJuEN ClyXIR/DIu7RWNy+JFkWhIg8sheUh+6mmHeGAKDOji93i3M7TuUgDrORz1594LzB1ebO DBww== X-Gm-Message-State: AOAM533kly2XMEaIaVxJmqBdgWdxpbtsHGaMDOsve/rBazhLJ1T2OnxI VSEXdC/Y9BoVPdhyHqjKFoLQ6dN9mjE7BJPYXTL8lU/qu1mom+ONguhP9Iad6VxfrXbu269L9sP JokIm/LmpMU8umPtNaQ== X-Received: by 2002:a05:620a:4686:: with SMTP id bq6mr8194008qkb.137.1638382893587; Wed, 01 Dec 2021 10:21:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFlNA90PpJowGB6LzkW0tmcKS/MwGBaJilcbyKX5lWQ4Iy3BLoAL/I9hrn66YhWIMcuAYegA== X-Received: by 2002:a05:620a:4686:: with SMTP id bq6mr8193982qkb.137.1638382893369; Wed, 01 Dec 2021 10:21:33 -0800 (PST) Received: from [192.168.0.102] ([104.219.122.97]) by smtp.gmail.com with ESMTPSA id l25sm243901qkk.48.2021.12.01.10.21.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Dec 2021 10:21:32 -0800 (PST) Message-ID: <1423649f-7ef6-7408-36dc-4865f458b45e@redhat.com> Date: Wed, 1 Dec 2021 13:21:31 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH] Loop unswitching: support gswitch statements. To: =?UTF-8?Q?Martin_Li=c5=a1ka?= , Richard Biener Cc: GCC Patches , Aldy Hernandez References: <0db1d9e8-f097-e766-a9fa-1a98c47b8115@suse.cz> <3a07ef98-d05f-dc07-2e36-a2b4ffd52936@suse.cz> <7bcc368c-3f26-4503-aec1-a3d6378e33ec@suse.cz> <561a3ffd-8973-d771-418f-76c484085cc5@suse.cz> <20265d97-6350-c234-695d-bc18e2e617b4@suse.cz> <1169b649-e3e2-36c9-f964-0b0ecd2530fa@suse.cz> <33509887-dfa3-6bb0-6fbe-cec8873f651f@suse.cz> From: Andrew MacLeod In-Reply-To: <33509887-dfa3-6bb0-6fbe-cec8873f651f@suse.cz> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, BODY_8BITS, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, 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-List-Received-Date: Wed, 01 Dec 2021 18:21:38 -0000 On 12/1/21 09:48, Martin Liška wrote: > On 12/1/21 15:34, Richard Biener wrote: >> On Wed, Dec 1, 2021 at 3:25 PM Martin Liška wrote: >>> >>> On 12/1/21 15:19, Richard Biener wrote: >>>> which is compute the range of 'lhs' on edge_true into >>>> predicate->true_range, >>>> assign that same range to ->false_range and then invert it to get the >>>> range on the false_edge.  What I am saying is that for better >>>> precision >>>> you should do >>>> >>>>        ranger->range_on_edge (predicate->false_range, edge_false, >>>> lhs); >>>> >>>> rather than prematurely optimize this to the inversion of the true >>>> range >>>> since yes, ranger is CFG sensitive and only the_last_ predicate on a >>>> long CFG path is actually inverted. >>>> >>>> What am I missing? >>> >>> I might be misunderstood, but I think it's the problem defined here: >>> https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584605.html >>> >>> where I used the ranger->range_on_edge on the false_edge. >> >> Ah, OK.  But then even the true_edge range is possibly wrong, no? > > You are of course correct, I've just proved that in debugger :// > >> Consider >> >>    for (;;) >>       { >>           if (a < 100) >>             if (a > 50)  // unswitch on this >>               /* .. */ >>           if (a < 120) >>               /* ... */ >>       } >> >> then you record [51, 99] for true_range of the a > 50 predicate and thus >> simplification will simplify the if (a < 120) check, no? > > Yep. > >> >> You can only record the range from the (CFG independent) a > 50 check, >> thus [51, +INF] but of course at simplification time you can also use >> the CFG context at each simplification location. > > @Andrew: How can I easily get irange based just on a stmt? Something > like fold_range > with int_range_max as the 3rd argument? > Sorry, I miss these things if I'm not directly CC'd a lot :-) So you just want to know the basic range the stmt generates without context?    Sure, what you say would be fine, but your want to initialize it to the type range: int_range_max range (TREE_TYPE (name)); you can also simply trigger it using the current SSA_NAME_RANGE_INFO global  values query instead of the default current contextual one... which , if there isnt a global range, will automatically use the range of the type of the argument.. so maybe just try fold_range (r, stmt, get_global_range_query ()) Andrew