Re: [patch] PR tree-optimization/96818 - cast label range to type of switch operand

2020-09-03 Thread Andrew MacLeod via Gcc-patches
On 9/3/20 3:43 AM, Richard Biener wrote: On Thu, Sep 3, 2020 at 9:21 AM Aldy Hernandez wrote: On 8/31/20 2:55 PM, Richard Biener wrote: On Mon, Aug 31, 2020 at 11:10 AM Aldy Hernandez wrote: On 8/31/20 10:33 AM, Richard Biener wrote: On Mon, Aug 31, 2020 at 10:20 AM Aldy Hernandez

Re: [PATCH] Allow copying of symbolic ranges to an irange.

2020-09-15 Thread Andrew MacLeod via Gcc-patches
On 9/15/20 11:57 AM, Aldy Hernandez wrote: This fixes an ICE when trying to copy a legacy value_range containing a symbolic to a multi-range: min = make_ssa_name (type); max = build_int_cst (type, 55); value_range vv (min, max); int_range<2> vr = vv; This doesn't affect

fixing commits?

2020-10-07 Thread Andrew MacLeod via Gcc-patches
When I broke r11-3684 temporarily yesterday, it was fixed in the next commit. But it does mean that for anyone bisecting a problem, theres a broken commit. Is there a blessed way to fix that? or does it stay broken forever? All I need to do is change a single line in gimple-range.h... or do

[PUSHED] Off by one final fix.

2020-10-07 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 2:59 PM, Andrew MacLeod via Gcc-patches wrote: On 10/6/20 2:41 PM, Andreas Schwab wrote: On Okt 06 2020, Andrew MacLeod via Gcc-patches wrote: diff --git a/gcc/value-range.h b/gcc/value-range.h index 7031a823138..02a952bf81f 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h

Re: [PUSHED] Hybrid EVRP and testcases

2020-10-07 Thread Andrew MacLeod via Gcc-patches
On 10/7/20 2:10 AM, Richard Biener wrote: On Tue, Oct 6, 2020 at 7:06 PM Andrew MacLeod via Gcc-patches wrote: I have now checked in the hybrid EVRP pass. We have resolved all the issue we are aware of with a full Fedora build, but if any more issues arise, please let us know. (And Im sure

Re: [PUSHED] Hybrid EVRP and testcases

2020-10-07 Thread Andrew MacLeod via Gcc-patches
On 10/7/20 11:19 AM, Aldy Hernandez wrote: On 10/7/20 8:10 AM, Richard Biener wrote: > On Tue, Oct 6, 2020 at 7:06 PM Andrew MacLeod via Gcc-patches > wrote: >> >> I have now checked in the hybrid EVRP pass. >> >> We have resolved all the issue we are awar

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-02 Thread Andrew MacLeod via Gcc-patches
On 10/2/20 9:26 AM, Martin Liška wrote: Yes, you simply get all sorts of conditions that hold when a condition is true, not just those based on the SSA name you put in.  But it occured to me that the use-case is somewhat different - for switch-conversion you want to know whether the test

Re: [patch] convert -Wrestrict pass to ranger

2020-10-05 Thread Andrew MacLeod via Gcc-patches
On 10/5/20 4:16 PM, Martin Sebor wrote: On 10/5/20 8:50 AM, Aldy Hernandez via Gcc-patches wrote: [Martin, as the original author of this pass, do you have any concerns?] @@ -1270,7 +1271,21 @@ get_size_range (tree exp, tree range[2], bool allow_zero /* = false */)     enum

Re: [patch] cleanup legacy_union and legacy intersect in value_range.

2020-10-05 Thread Andrew MacLeod via Gcc-patches
On 10/5/20 11:51 AM, Aldy Hernandez wrote: More changes from the ranger branch that been tested and retested, including a full Fedora build. These are cleanups so that multi-range union/intersect doesn't have to deal with legacy code.  Instead, these should be done in legacy mode. OK

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 6:22 AM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 11:20:52AM +0200, Aldy Hernandez wrote: diff --git a/gcc/value-range.h b/gcc/value-range.h index 94b48e55e77..7031a823138 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -670,7 +670,7 @@

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 8:09 AM, Martin Liška wrote: On 10/2/20 4:19 PM, Andrew MacLeod wrote: On 10/2/20 9:26 AM, Martin Liška wrote: Yes, you simply get all sorts of conditions that hold when a condition is true, not just those based on the SSA name you put in.  But it occured to me that the use-case is

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 9:09 AM, Martin Liška wrote: On 10/6/20 2:56 PM, Andrew MacLeod wrote: Ah, by just using the outgoing_range class, all you are getting is static edges.  so a TRUE edge is always a [1,1] and a false edge is [0,0] I provided that class so you could get the constant edges on switches.

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 8:55 AM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 08:47:53AM -0400, Andrew MacLeod wrote: I think the proper alignment will be guaranteed if irange and tree[] are obstack_alloc'd separately. They don't need to be adjacent, do they? They do not, it just seemed wasteful to do 2

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 6:40 AM, Andreas Schwab wrote: On Okt 06 2020, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 10:47:34AM +0200, Andreas Schwab wrote: On Okt 06 2020, Jakub Jelinek via Gcc-patches wrote: I mean, we could just use: size_t nbytes = sizeof (irange) + sizeof (tree) * 2 * num_pairs;

Re: [patch] convert -Wrestrict pass to ranger

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 10:30 AM, Martin Sebor wrote: On 10/6/20 3:45 AM, Aldy Hernandez wrote: -  builtin_memref dstref (dst, dstsize); -  builtin_memref srcref (src, srcsize); +  builtin_memref dstref (query, call, dst, dstsize); +  builtin_memref srcref (query, call, src, srcsize);     /* Create a

[PUSHED] Ranger classes.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
I have checked in the ranger classes/files.    They are being built but not being invoked until the other passes are checked in. there are 8 new files: gimple-range-cache.{h,cc} :   Various caches used by the ranger. gimple-range-edge.{h,cc} :    Outgoing edge range calculations, particularly

[PATCH] Don't invoke range_of_expr multiple times.

2020-10-16 Thread Andrew MacLeod via Gcc-patches
In the hybrid folder, range_of_stmt and range_on_edge invoke the same routines in both evrp_folder and ranger_folder and compare results. In implementing hybrid folder, I inherited it from evrp_folder since EVRP has a few pre-and post statement things to do. when the hybdrid folder calls

[PATCH] Don't assert on a negative shift.

2020-10-16 Thread Andrew MacLeod via Gcc-patches
We were asserting that the shifts should not be negative, instead, just return false indicating we can't tell anything about operand1 from the result. Bootstrapped on x86_64-pc-linux-gnu,  no regressions, pushed. Andrew 2020-10-16 Andrew Macleod PR tree-optimization/97462 gcc/ *

[PATCH] Don't display ranges for dead ssa-names.

2020-10-16 Thread Andrew MacLeod via Gcc-patches
AS Jakub  observed in an earlier testcase (97325),  when EVRP dumps the known SSA_RANGES, it isn't expecting names to be deleted that it could not delete, so it wasn't checking. With the hybrid model, ranger sometimes deletes things that EVRP calculated a range for, and the resulting dump was

[PATCH] pointer_plus [0, 0] + const folding

2020-10-16 Thread Andrew MacLeod via Gcc-patches
In order to match evrp behaviour, adjust POINTER_PLUS_EXPR processing to handle a zero constant plus something to return the something. ie [0, 0]  + CONST    will now return [CONST, CONST] instead of the previous behaviour of [1, +INF]. Bootstrapped on x86_64-pc-linux-gnu, no regressions,

Re: [PATCH] Gracefully handle right shifts larger than the precision.

2020-10-19 Thread Andrew MacLeod via Gcc-patches
On 10/19/20 6:36 AM, Aldy Hernandez wrote: The test is trying to shift by 129, but the underlying type is 128 bits. This causes low_bits to wrap around to -1 and things go bad really quick. Attached is my proposed solution. Andrew, do you have a preference on how to fix this? If we know we

Re: [PATCH] Handle right shifts by zero in range-ops.

2020-10-19 Thread Andrew MacLeod via Gcc-patches
On 10/19/20 5:38 AM, Aldy Hernandez wrote: If the shift amount in operator_lshift::op1_range was zero, an invalid range of [1, 0] was being created. Should we do the same thing with rshift::op1_range? ie, return the LHS if the shift is 0 instead of trying to figure it out Pushed.

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual documents the [0] extension and mentions but discourages using [1]. Nothing is said about other sizes and the warnings such as -Warray-bounds have been increasingly

Re: [PATCH 2/6] gimple-range-edge

2020-10-05 Thread Andrew MacLeod via Gcc-patches
On 10/5/20 8:09 AM, Jakub Jelinek wrote: On Fri, Oct 02, 2020 at 12:59:54PM -0400, Andrew MacLeod via Gcc-patches wrote: The ranger is needed to map those values to the switch variable, and also apply any previous ranges or derived values (ie, if you ask for the range of 'y' in case 2

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 2:41 PM, Andreas Schwab wrote: On Okt 06 2020, Andrew MacLeod via Gcc-patches wrote: diff --git a/gcc/value-range.h b/gcc/value-range.h index 7031a823138..02a952bf81f 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -668,13 +668,12 @@ irange_allocator::allocate (unsigned

Re: error: ‘EVRP_MODE_DEBUG’ was not declared – was: [PUSHED] Ranger classes.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 12:56 PM, Tobias Burnus wrote: Build fails here now with: gimple-range.h:168:59: error: ‘EVRP_MODE_DEBUG’ was not declared in this scope Tobias On 10/6/20 6:49 PM, Andrew MacLeod via Gcc-patches wrote: I have checked in the ranger classes/files.    They are being built

Re: error: ‘EVRP_MODE_DEBUG’ was not declared – was: [PUSHED] Ranger classes.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:10 PM, Tobias Burnus wrote: On 10/6/20 6:56 PM, Tobias Burnus wrote: Build fails here now with: gimple-range.h:168:59: error: ‘EVRP_MODE_DEBUG’ was not declared in this scope And now builds – as the "Hybrid EVRP and testcases" was pushed as well, a bit more than a quarter of an

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:48 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual documents the [0] extension and mentions but discourages

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 2:18 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 02:09:42PM -0400, Andrew MacLeod wrote: + size_t nbytes = sizeof (tree) * 2 * num_pairs; + + // Allocate the irnge and required memory for the vector + void *r = (irange *) obstack_alloc (_obstack, sizeof (irange)); Then

[PUSHED] Hybrid EVRP and testcases

2020-10-06 Thread Andrew MacLeod via Gcc-patches
I have now checked in the hybrid EVRP pass. We have resolved all the issue we are aware of with a full Fedora build, but if any more issues arise, please let us know. (And Im sure you will :-) I made some minor tweaks.   the option to the new -fevrp-mode  flag are now: legacy             :

Re: [PUSHED] Fix off-by-one storage problem in irange_allocator.

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 1:58 PM, Andrew MacLeod via Gcc-patches wrote: On 10/6/20 1:48 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 01:41:54PM -0400, Andrew MacLeod wrote: On 10/6/20 1:32 PM, Jakub Jelinek via Gcc-patches wrote: On Tue, Oct 06, 2020 at 10:42:12AM -0600, Martin Sebor wrote: The manual

Re: [patch] convert -Wrestrict pass to ranger

2020-10-06 Thread Andrew MacLeod via Gcc-patches
On 10/6/20 3:27 PM, Martin Sebor wrote: On 10/5/20 8:18 PM, Andrew MacLeod wrote: On 10/5/20 4:16 PM, Martin Sebor wrote: Long term, I would expect we might have some sort of general access... probably thru cfun.     so any pass/routines would just ask for      RANGE_INFO

Re: [patch] Import various range-op fixes from the ranger branch.

2020-10-05 Thread Andrew MacLeod via Gcc-patches
On 10/5/20 11:19 AM, Aldy Hernandez wrote: This patch imports three fixes from the ranger branch: 1. Fold division by zero into varying instead of undefined. This provides compatibility with existing stuff on trunk. 2. Solver changes for lshift and rshift. This should not affect anything on

Re: UX ideas for diagnostics involving ranges (was Re: [patch] convert -Walloca pass to ranger)

2020-10-05 Thread Andrew MacLeod via Gcc-patches
On 10/5/20 11:28 AM, David Malcolm via Gcc-patches wrote: On Mon, 2020-10-05 at 11:51 +0200, Aldy Hernandez via Gcc-patches wrote: The walloca pass is a mess. It has all sorts of heuristics to divine problematic ranges fed into alloca, none of them very good, and all of them unreadable. The

Re: [PATCH] Add if-chain to switch conversion pass.

2020-10-14 Thread Andrew MacLeod via Gcc-patches
On 10/12/20 8:39 AM, Martin Liška wrote: On 10/6/20 4:12 PM, Jakub Jelinek wrote: On Tue, Oct 06, 2020 at 03:48:38PM +0200, Martin Liška wrote: On 10/6/20 9:47 AM, Richard Biener wrote: But is it really extensible with the current implementation?  I doubt so. I must agree with the

Re: [PUSHED] operator_trunc_mod::wi_fold: Return VARYING for mod by zero.

2020-10-14 Thread Andrew MacLeod via Gcc-patches
On 10/13/20 2:10 AM, Richard Biener wrote: On Mon, Oct 12, 2020 at 6:57 PM Aldy Hernandez via Gcc-patches wrote: Division by zero should return VARYING, otherwise we propagate undefine all over the ranger and cause bad things to happen :) So we never should propagate UNDEFINED? I added a

[patch] Use precision and sign to compare types for ranges

2020-10-19 Thread Andrew MacLeod via Gcc-patches
This fixes the second test case in pr 97360. There are a few places in the ranger where we sanity check the types of the ranges.  We were using types_compatible_p() but thats not really acccurate as gimple allows types which are useless_type_conversion_p() in only one direction, whereas

Re: PING: Fwd: [PATCH 2/2] Decouple adjust_range_from_scev from vr_values and value_range_equiv.

2020-08-18 Thread Andrew MacLeod via Gcc-patches
On 8/18/20 12:38 PM, Aldy Hernandez wrote: And here's the patch without the sanity check. Aldy That diff was difficult to read.. I had to apply the patch to really follow it :-P Anyway, yeah, this looks better.  effectively, you have   1) left the input range "vr" range merging in

Re: std:vec for classes with constructor? (Was: Re: [patch] multi-range implementation for value_range (irange))

2020-08-24 Thread Andrew MacLeod via Gcc-patches
On 8/24/20 5:53 PM, Jeff Law wrote: On Wed, 2020-08-05 at 17:41 +0200, Aldy Hernandez wrote: On 8/5/20 5:09 PM, Martin Jambor wrote: On Fri, Jul 31 2020, Aldy Hernandez via Gcc-patches wrote: [...] * ipa-cp changes from vec to std::vec. We are using std::vec to ensure constructors are

Re: PING: Fwd: [PATCH 2/2] Decouple adjust_range_from_scev from vr_values and value_range_equiv.

2020-08-14 Thread Andrew MacLeod via Gcc-patches
On 8/14/20 12:05 PM, Aldy Hernandez wrote: I made some minor changes to the function comments. gcc/ChangeLog: * vr-values.c (check_for_binary_op_overflow): Change type of store to range_query. (vr_values::adjust_range_with_scev): Abstract most of the code...

Re: PING: Fwd: [PATCH 2/2] Decouple adjust_range_from_scev from vr_values and value_range_equiv.

2020-08-17 Thread Andrew MacLeod via Gcc-patches
On 8/17/20 6:04 AM, Aldy Hernandez wrote: On 8/14/20 7:16 PM, Andrew MacLeod wrote: On 8/14/20 12:05 PM, Aldy Hernandez wrote: I made some minor changes to the function comments. gcc/ChangeLog: * vr-values.c (check_for_binary_op_overflow): Change type of store to range_query.

Re: [PATCH] generalized range_query class for multiple contexts

2020-09-25 Thread Andrew MacLeod via Gcc-patches
On 9/24/20 5:51 PM, Martin Sebor via Gcc-patches wrote: On 9/18/20 12:38 PM, Aldy Hernandez via Gcc-patches wrote: 3. Conversion of sprintf/strlen pass to class. This is a nonfunctional change to the sprintf/strlen passes. That is, no effort was made to change the passes to multi-ranges. 

Re: [PATCH] generalized range_query class for multiple contexts

2020-09-25 Thread Andrew MacLeod via Gcc-patches
On 9/23/20 7:53 PM, Martin Sebor via Gcc-patches wrote: On 9/18/20 12:38 PM, Aldy Hernandez via Gcc-patches wrote: As part of the ranger work, we have been trying to clean up and generalize interfaces whenever possible. This not only helps in reducing the maintenance burden going forward, but

Re: [PATCH] generalized range_query class for multiple contexts

2020-09-30 Thread Andrew MacLeod via Gcc-patches
On 9/25/20 1:41 PM, Andrew MacLeod via Gcc-patches wrote: On 9/23/20 7:53 PM, Martin Sebor via Gcc-patches wrote: On 9/18/20 12:38 PM, Aldy Hernandez via Gcc-patches wrote: As part of the ranger work, we have been trying to clean up and generalize interfaces whenever possible. This not only

Re: [PATCH] generalized range_query class for multiple contexts

2020-10-01 Thread Andrew MacLeod via Gcc-patches
On 10/1/20 5:05 AM, Aldy Hernandez via Gcc-patches wrote: Thanks for doing all this! There isn't anything I don't understand in the sprintf changes so no questions from me (well, almost none). Just some comments: Thanks for your comments on the sprintf/strlen API conversion. The current call

Re: [PATCH] Fix build of ppc64 target.

2020-10-01 Thread Andrew MacLeod via Gcc-patches
On 10/1/20 5:30 PM, David Edelsohn wrote: * config/rs6000/rs6000-call.c: Include value-range.h. * config/rs6000/rs6000.c: Likewise. This is okay for trunk, thanks! (It is trivial and obvious as well, so please just commit things like this without prior approval.) This patch is not the correct

Re: [PATCH] warn for integer overflow in allocation calls (PR 96838)

2020-09-17 Thread Andrew MacLeod via Gcc-patches
On 9/17/20 12:08 PM, Martin Sebor via Gcc-patches wrote: On 9/16/20 9:23 PM, Jeff Law wrote: On 9/15/20 1:47 PM, Martin Sebor wrote: Overflowing the size of a dynamic allocation (e.g., malloc or VLA) can lead to a subsequent buffer overflow corrupting the heap or stack.  The attached patch

Re: [PATCH] irange_pool class

2020-09-18 Thread Andrew MacLeod via Gcc-patches
On 9/18/20 1:07 PM, Martin Sebor wrote: On 9/18/20 8:10 AM, Aldy Hernandez via Gcc-patches wrote: On 9/18/20 2:28 PM, David Malcolm wrote: On Fri, 2020-09-18 at 07:49 +0200, Aldy Hernandez wrote: On 9/18/20 3:43 AM, David Malcolm wrote: On Thu, 2020-09-17 at 12:36 +0200, Aldy Hernandez

Re: [PATCH] irange_pool class

2020-09-18 Thread Andrew MacLeod via Gcc-patches
On 9/18/20 4:35 PM, Martin Sebor wrote: On 9/18/20 11:36 AM, Andrew MacLeod wrote: On it works exactly like one would expect a simple allocator to work.. as long as the allcoator is "live", its allocations are live.  once it is destructed, all the memory it manages is freed..    It purpose

Re: [PATCH] generalized range_query class for multiple contexts

2020-09-28 Thread Andrew MacLeod via Gcc-patches
On 9/28/20 11:27 AM, Martin Sebor wrote: On 9/25/20 11:41 AM, Andrew MacLeod wrote: Since you have replied to this thread, whats your opinion whether there should be an extra API entry point for range/value_after_stmt or whether that should be rolled into  the range_of_stmt routine, and

Re: [PATCH] irange_pool class

2020-09-28 Thread Andrew MacLeod via Gcc-patches
On 9/18/20 1:03 PM, Aldy Hernandez wrote: On 9/18/20 6:42 PM, Andrew MacLeod wrote: On 9/18/20 8:28 AM, David Malcolm wrote:I think of a "pool allocator" as something that makes a small number of large allocation under the covers, and then uses that to serve large numbers of fixed sized small

[PATCH 3/6] gimple-range-gori

2020-10-02 Thread Andrew MacLeod via Gcc-patches
This is the true core of the ranger. The GORI (Generates Outgoing Range Information) engine contains all the smarts to utilize the functionality provided via range-ops in order to calculate outgoing ranges on an edge, based on the control flow at the exit. It functions *only* at the basic

Project Ranger Submission / On Demand VRP

2020-10-02 Thread Andrew MacLeod via Gcc-patches
Where to start?   This is the culmination of numerous years work on the ranger for generating accurate on-demand ranges in GCC. There are 2 patch sets as a part of this submission 1)  The ranger &  Enhancements to EVRP 3)  Other passes converted to Ranger There is still some missing

[PATCH 4/6] gimple-range-cache

2020-10-02 Thread Andrew MacLeod via Gcc-patches
These are the various caches used by the ranger. - non-null-ref :  Tracks non-null pointer dereferences in blocks so we can properly calculate non-null pointer ranges - on entry cache : Block ranges tracks the calucalted values sof ssa-names on entry to each basic block. - global cache: 

[PATCH 5/6] gimple-range

2020-10-02 Thread Andrew MacLeod via Gcc-patches
This is the ranger component that pulls all the others bits together. Its API is basically the range_query we've already pushed into the compiler. The main ones a client are likely to use are bool range_of_stmt (irange , gimple *, tree name = NULL) bool range_of_expr (irange , tree name,

[PATCH 2/6] gimple-range-edge

2020-10-02 Thread Andrew MacLeod via Gcc-patches
This file produces constant edge ranges.  It provides a class which can be instantiated and will return the range on any edge. This was originally suppose to be trivial, but switches mucked that up :-) There are 2 basic expressions that can result ina  constant range on an edge: Note there is

[PATCH 1/6] Ranger patches.

2020-10-02 Thread Andrew MacLeod via Gcc-patches
This patch set contains the various components that make up a ranger. Ranger files are prefixed by   "gimple-range". gimple-range-cache.{h,cc} :   Various caches used by the ranger. gimple-range-edge.{h,cc} :    Outgoing edge range calculations, particularly switch edge ranges.

[PATCH 6/6] Hybrid EVRP

2020-10-02 Thread Andrew MacLeod via Gcc-patches
The patch switches to a hybrid EVRP pass which utilizes both the Ranger and the classic EVRP pass. it introduces a new undocumented option: -fevrp-mode=   which can be one of the following options evrp-only    : This is classic EVRP mode, identical to whats in trunk now. rvrp-only     : This

Re: [PATCH] irange_pool class

2020-09-19 Thread Andrew MacLeod via Gcc-patches
On 9/19/20 4:32 PM, Martin Sebor wrote: On 9/18/20 3:09 PM, Andrew MacLeod wrote: O What I meant by proxy is a substitute class each of whose objects stands in for a single instance of int_range where N is a runtime value.   There's no class like that. [Just to be clear, I don't meant for

Re: [PATCH] Allow copying of symbolic ranges to an irange.

2020-09-16 Thread Andrew MacLeod via Gcc-patches
On 9/16/20 12:25 PM, Aldy Hernandez wrote: >>  // Swap min/max if they are out of order.  Return TRUE if further > these seems OK, but can't there be anti-ranges with symbolics  too? ie > ~[a_12, a_12] > The code for that just does: > >   else if (src.kind () == VR_ANTI_RANGE) >  set

Re: [PATCH] irange_pool class

2020-09-18 Thread Andrew MacLeod via Gcc-patches
On 9/18/20 8:28 AM, David Malcolm wrote:I think of a "pool allocator" as something that makes a small number of large allocation under the covers, and then uses that to serve large numbers of fixed sized small allocations and deallocations with O(1) using a free list. Ah, I didn't know pool had

Re: [PATCH] irange_pool class

2020-09-21 Thread Andrew MacLeod via Gcc-patches
On 9/19/20 4:32 PM, Martin Sebor wrote: On 9/18/20 3:09 PM, Andrew MacLeod wrote: On 9/18/20 4:35 PM, Martin Sebor wrote: Do you really need 6 or 10 subranges to find out the answer to the questions you are looking for?  most of the time, 2 or 3 pairs carries all the information anyone needs

[PATCH] Handle a_2= properly in range calculations.

2020-10-21 Thread Andrew MacLeod via Gcc-patches
Pick up the correct type for the RHS of  a_2 = bootstrapped on  x86_64-pc-linux-gnu, no regressions, pushed. Andrew commit 966fdb2e12c0347aa3f9efaf5f4e1cd8237fa024 Author: Andrew MacLeod Date: Wed Oct 21 20:11:16 2020 -0400 Handle a_2= properly in range calculations. when

[PATCH] Check for undefined before not returning a constant value

2020-10-21 Thread Andrew MacLeod via Gcc-patches
Full comments in the PR, but basically substitute and fold was expecting to see a constant returned for any range which globally evaluates to a constant. This allowed it to replace all uses of an ssa name as they were encountered. The ranger model can return UNDEFINED for the range of names in

Re: PING: Fwd: [PATCH] Refactor range handling of builtins in vr_values and ranger.

2020-10-20 Thread Andrew MacLeod via Gcc-patches
On 10/19/20 6:03 AM, Aldy Hernandez wrote: Forwarded Message Subject: [PATCH] Refactor range handling of builtins in vr_values and ranger. Date: Fri,  9 Oct 2020 14:32:05 +0200 From: Aldy Hernandez To: GCC patches , Jakub Jelinek CC: Andrew MacLeod , Aldy Hernandez

Re: PING: [PATCH] Convert -Walloca pass to ranger.

2020-10-20 Thread Andrew MacLeod via Gcc-patches
On 10/19/20 1:16 PM, Aldy Hernandez wrote: Rebased on current trunk. FWIW, we finally get rid of the Walloca-6.c XFAIL. This has been a long time in coming: -/* { dg-xfail-if "Currently broken but Andrew's work should fix this" { *-*-* } } */ :-) OK? You are the original author of this

Re: [PATCH] Remove vr_values::extract_range_builtin.

2020-10-20 Thread Andrew MacLeod via Gcc-patches
On 10/20/20 12:43 PM, Aldy Hernandez wrote: As promised. Now that we know the vr_values and ranger versions are in sync, it is safe to remove the vr_values version and just call the ranger one. I am holding off on pushing this for a week or two, or until Fedora gets rebuilt with the current

Re: PING: [PATCH] Convert -Wrestrict pass to ranger.

2020-10-20 Thread Andrew MacLeod via Gcc-patches
On 10/19/20 1:23 PM, Aldy Hernandez wrote: Rebased on current trunk. There is one adjustment to a C++ test which now gives a false positive. After talking with Martin Sebor, we've concluded this is expected. There is no way to communicate that libstdc++ allocated objects are always less than

[PATCH] Combine logical OR ranges properly. pr97567

2020-10-26 Thread Andrew MacLeod via Gcc-patches
In the core of gori_compute::logical_combine we are suppose to combine the calculated true and false ranges on each side of  the operation. when encountering [0,0] =   c_3  | c_4 we know we only need to consider the FALSE values of the range carried by c_3 and c_4, but it can be EITHER of

[PATCH] Tweaks to ranger API routines.

2020-10-27 Thread Andrew MacLeod via Gcc-patches
There are a couple of little things I've been meaning to get to. 1)  The API routines return TRUE when a range has been computed, and false when one cannot be. The range itself was uninitialized when false was returned, and this was a bit awkward by times. Now, when false is returned, the

Re: [PATCH] value-range: Give up on POLY_INT_CST ranges [PR97457]

2020-10-28 Thread Andrew MacLeod via Gcc-patches
On 10/28/20 5:43 AM, Richard Sandiford via Gcc-patches wrote: This PR shows another problem with calculating value ranges for POLY_INT_CSTs. We have: ivtmp_76 = ASSERT_EXPR POLY_INT_CST [9, 4294967294]> where the VQ coefficient is unsigned but is effectively acting as a negative number.

Re: [PATCH] Combine logical OR ranges properly. pr97567

2020-10-27 Thread Andrew MacLeod via Gcc-patches
On 10/27/20 7:23 AM, Christophe Lyon wrote: Hi, On Mon, 26 Oct 2020 at 22:51, Andrew MacLeod via Gcc-patches wrote: In the core of gori_compute::logical_combine we are suppose to combine the calculated true and false ranges on each side of the operation. when encountering [0,0] = c_3

Re: [PATCH] Combine logical OR ranges properly. pr97567

2020-10-27 Thread Andrew MacLeod via Gcc-patches
On 10/27/20 10:44 AM, H.J. Lu wrote: On Tue, Oct 27, 2020 at 7:18 AM Andrew MacLeod via Gcc-patches wrote: On 10/27/20 7:23 AM, Christophe Lyon wrote: Hi, On Mon, 26 Oct 2020 at 22:51, Andrew MacLeod via Gcc-patches wrote: In the core of gori_compute::logical_combine we are suppose

[PATCH] Re: error: ‘EVRP_MODE_DEBUG’ was not declared – was: [PUSHED] Ranger classes.

2020-10-26 Thread Andrew MacLeod via Gcc-patches
On 10/25/20 8:37 PM, Maciej W. Rozycki wrote: On Tue, 6 Oct 2020, Andrew MacLeod via Gcc-patches wrote: Build fails here now with: gimple-range.h:168:59: error: ‘EVRP_MODE_DEBUG’ was not declared in this scope And now builds – as the "Hybrid EVRP and testcases" was pushed as well,

Re: [PATCH] Rewrite get_size_range for irange API.

2020-08-10 Thread Andrew MacLeod via Gcc-patches
On 8/10/20 12:35 PM, Martin Sebor via Gcc-patches wrote: On 8/10/20 5:47 AM, Aldy Hernandez wrote: On 8/6/20 9:30 PM, Martin Sebor wrote: On 8/6/20 8:53 AM, Aldy Hernandez via Gcc-patches wrote: +  // Remove the unknown parts of a multi-range. +  // This will transform [5,10][20,MAX] into

Re: [PATCH] Rewrite get_size_range for irange API.

2020-08-10 Thread Andrew MacLeod via Gcc-patches
On 8/10/20 2:46 PM, Martin Sebor wrote: On 8/10/20 11:50 AM, Andrew MacLeod wrote: On 8/10/20 12:35 PM, Martin Sebor via Gcc-patches wrote: On 8/10/20 5:47 AM, Aldy Hernandez wrote: On 8/6/20 9:30 PM, Martin Sebor wrote: On 8/6/20 8:53 AM, Aldy Hernandez via Gcc-patches wrote: +  //

Re: [PATCH] Rewrite get_size_range for irange API.

2020-08-10 Thread Andrew MacLeod via Gcc-patches
On 8/10/20 2:46 PM, Martin Sebor wrote: On 8/10/20 11:50 AM, Andrew MacLeod wrote: On 8/10/20 12:35 PM, Martin Sebor via Gcc-patches wrote: On 8/10/20 5:47 AM, Aldy Hernandez wrote: int_range is the type which allows for up to X subranges. calculations will be merged to fit within X

Re: std:vec for classes with constructor? (Was: Re: [patch] multi-range implementation for value_range (irange))

2020-08-05 Thread Andrew MacLeod via Gcc-patches
On 8/5/20 12:54 PM, Richard Biener via Gcc-patches wrote: On August 5, 2020 5:09:19 PM GMT+02:00, Martin Jambor wrote: On Fri, Jul 31 2020, Aldy Hernandez via Gcc-patches wrote: [...] * ipa-cp changes from vec to std::vec. We are using std::vec to ensure constructors are run, which they

Re: PING: Fwd: [PATCH 1/2] Add statement context to get_value_range.

2020-08-14 Thread Andrew MacLeod via Gcc-patches
On 8/11/20 7:53 AM, Aldy Hernandez via Gcc-patches wrote: -- Forwarded message - From: Aldy Hernandez Date: Tue, Aug 4, 2020, 13:55 Subject: [PATCH 1/2] Add statement context to get_value_range. To: Cc: , Aldy Hernandez This is in line with the statement context that we have

Re: make FOR_EACH_IMM_USE_STMT safe for early exits

2021-01-12 Thread Andrew MacLeod via Gcc-patches
On 1/9/21 3:33 PM, Alexandre Oliva wrote: On Jan 7, 2021, Richard Biener wrote: On Wed, Jan 6, 2021 at 12:34 PM Alexandre Oliva wrote: On Jan 4, 2021, Richard Biener wrote: Thus, please remove uses of BREAK_FROM_IMM_USE_STMT together with this patch. And RETURN_FROM_IMM_USE_STMT, I

Re: [PATCH] match.pd: Use ranges to optimize some x * y / y to x [PR97997]

2020-11-30 Thread Andrew MacLeod via Gcc-patches
On 11/26/20 3:52 AM, Jakub Jelinek wrote: Hi! For signed integers with undefined overflow we already optimize x * y / y into x, but for signed integers with -fwrapv or unsigned integers we don't. The following patch allows optimizing that into just x if value ranges prove that x * y will never

Re: [PATCH] warn for integer overflow in allocation calls (PR 96838)

2020-11-21 Thread Andrew MacLeod via Gcc-patches
On 11/21/20 12:07 AM, Jeff Law wrote: On 11/9/20 9:00 AM, Martin Sebor wrote: Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554000.html Jeff, I don't expect to have the cycles to reimplement this patch using the Ranger APIs before stage 1 closes.  I'm open to giving it a try

Re: [PATCH] warn for integer overflow in allocation calls (PR 96838)

2020-11-24 Thread Andrew MacLeod via Gcc-patches
On 11/24/20 12:42 PM, Andrew MacLeod wrote: On 11/23/20 4:38 PM, Martin Sebor wrote: On 11/21/20 6:26 AM, Andrew MacLeod wrote: On 11/21/20 12:07 AM, Jeff Law wrote: On 11/9/20 9:00 AM, Martin Sebor wrote: Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554000.html Jeff, I

Re: [PATCH] warn for integer overflow in allocation calls (PR 96838)

2020-11-24 Thread Andrew MacLeod via Gcc-patches
On 11/23/20 4:38 PM, Martin Sebor wrote: On 11/21/20 6:26 AM, Andrew MacLeod wrote: On 11/21/20 12:07 AM, Jeff Law wrote: On 11/9/20 9:00 AM, Martin Sebor wrote: Ping: https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554000.html Jeff, I don't expect to have the cycles to reimplement

[PATCH] [PR tree-optimization/97750] Fix trap in pointer conversion in op1_range.

2020-12-17 Thread Andrew MacLeod via Gcc-patches
operator_cast::op1_range() does some masking and calculations when a higher precision value is cast to a lower precision one. ie,  it fills in the ranges for the upper bits and trys to produce more usable results for the wind-back process.  Part of that calculation involved using PLUS_EXPR to

[patch] [PR tree-optimization/98174] Reduce memory requirements for ranger

2020-12-10 Thread Andrew MacLeod via Gcc-patches
With very large CFG's ranger on entry cache is not particularly efficient. One thing I never got to was recognizing that if an ssa-name is never used in an outgoing edge calculation, then its range never changes.. the global range is sufficient and we do not need to propagate the on-entry

Re: [r11-6232 Regression] FAIL: gcc.dg/pr97750.c (test for warnings, line 17) on Linux/x86_64

2020-12-18 Thread Andrew MacLeod via Gcc-patches
On 12/17/20 1:37 PM, sunil.k.pandey wrote: On Linux/x86_64, c25b504636fec7bf8f181a84af83a52757ba7e89 is the first bad commit commit c25b504636fec7bf8f181a84af83a52757ba7e89 Author: Andrew MacLeod Date: Thu Dec 17 09:24:11 2020 -0500 Fix trap in pointer conversion in op1_range. caused

Re: [ranger] Fix wrong code for boolean negation in condition at -O

2020-11-09 Thread Andrew MacLeod via Gcc-patches
On 11/9/20 4:38 PM, Eric Botcazou wrote: Hi, this is a regression present on mainline in the form of wrong code generated for the attached Ada testcase at -O -ftree-vrp. It's again an issue with the 8-bit booleans in Ada and, as a matter of fact, it's exactly the same issue as the one I fixed

Re: [PATCH] generalized range_query class for multiple contexts

2020-11-09 Thread Andrew MacLeod via Gcc-patches
On 11/5/20 2:29 PM, Martin Sebor wrote: On 10/1/20 11:25 AM, Martin Sebor wrote: I have applied the patch and ran some tests.  There are quite a few failures (see the list below).  I have only looked at a couple.  The one in in gcc.dg/tree-ssa/builtin-sprintf-warn-3.c boils down to the

Fix logical_combine OR operation. Again.

2020-11-09 Thread Andrew MacLeod via Gcc-patches
Doh. The original fix for PR97657 was incorrect.  It papered over a problem by reducing opportunities it could find. Given   if (c_2 || c_3) If the FALSE edge is taken, this is ! (c_2 || c_3) which is equivalent to !c_2 && !c_3.. so performing the intersection as combine_logical was

Re: [PATCH] Use extremes of underlying type when building VR_ANTI_RANGEs.

2020-11-10 Thread Andrew MacLeod via Gcc-patches
On 11/10/20 5:41 AM, Aldy Hernandez wrote: [Andrew, this doesn't fix a PR per se. It's just something I stumbled upon in my other -fstrict-enums fixes. It passes tests. What do you think? Should we push it?] Imagine an enum in an -fstrict-enums world: enum foo { zero, one, two,

Re: Fix gimple_expr_code?

2020-11-12 Thread Andrew MacLeod via Gcc-patches
On 11/12/20 3:53 PM, Richard Biener wrote: On November 12, 2020 9:43:52 PM GMT+01:00, Andrew MacLeod via Gcc-patches wrote: So I spent some time tracking down a ranger issue, and in the end, it boiled down to the range-op handler not being picked up properly. The handler is picked up

Fix gimple_expr_code?

2020-11-12 Thread Andrew MacLeod via Gcc-patches
So I spent some time tracking down a ranger issue, and in the end, it boiled down to the range-op handler not being picked up properly. The handler is picked up by:   if ((gimple_code (s) == GIMPLE_ASSIGN) || (gimple_code (s) == GIMPLE_COND))     return range_op_handler (gimple_expr_code

[PATCH] Change range_handler, was Re: Fix gimple_expr_code?

2020-11-12 Thread Andrew MacLeod via Gcc-patches
On 11/12/20 4:12 PM, Andrew MacLeod via Gcc-patches wrote: On 11/12/20 3:53 PM, Richard Biener wrote: ...  But it means that gimple_expr_code() isn't returning the correct result for GIMPLE_SINGLE_RHS It depends. A SSA name isn't an expression code either. As said, the generic

[PATCH] Re: Fix gimple_expr_code?

2020-11-13 Thread Andrew MacLeod via Gcc-patches
On 11/13/20 4:05 AM, Richard Biener wrote: On Thu, Nov 12, 2020 at 10:12 PM Andrew MacLeod <mailto:amacl...@redhat.com>> wrote: On 11/12/20 3:53 PM, Richard Biener wrote: > On November 12, 2020 9:43:52 PM GMT+01:00, Andrew MacLeod via Gcc-patches mailto:gcc-patches

[PATCH] Process only valid shift ranges.

2020-11-19 Thread Andrew MacLeod via Gcc-patches
When shifting outside the valid range of [0, precision-1], we can choose to process just the valid ones since the rest is undefined. This allows us to produce results for x << [0,2][+INF, +INF] by discarding  the invalid ranges and processing just [0,2]. THis is particularly important when

Re: [PATCH] ranger: Improve a % b operand ranges [PR91029]

2020-11-19 Thread Andrew MacLeod via Gcc-patches
On 11/19/20 5:41 PM, Jakub Jelinek wrote: Hi! As mentioned in the PR, the previous PR91029 patch was testing op2 >= 0 which is unnecessary, even negative op2 values will work the same, furthermore, from if a % b > 0 we can deduce a > 0 rather than just a >= 0 (0 % b would be 0), and it actually

re: FAIL: gcc.dg/pr97515.c

2020-11-20 Thread Andrew MacLeod via Gcc-patches
On 11/19/20 10:56 PM, sunil.k.pandey wrote: On Linux/x86_64, d0d8b5d83614d8f0d0e40c0520d4f40ffa01f8d9 is the first bad commit commit d0d8b5d83614d8f0d0e40c0520d4f40ffa01f8d9 Author: Andrew MacLeod Date: Thu Nov 19 17:41:30 2020 -0500 Process only valid shift ranges. caused FAIL:

Re: [PATCH] recognize implied ranges for modulo.

2020-11-18 Thread Andrew MacLeod via Gcc-patches
On 11/18/20 3:35 AM, Aldy Hernandez wrote: On 11/17/20 11:01 PM, Andrew MacLeod wrote: PR 91029 observes when   a % b > 0 && b >= 0, then a has an implied range of  a >=0.  likewise Shouldn't that be && b > 0?  b == 0 is undefined. If you were folding, sure, but  I think its OK for

[PATCH] IOR with nonzero, range cannot contain 0.

2020-11-17 Thread Andrew MacLeod via Gcc-patches
PR 83072 mentions that we have lost the ability to recognize that when we see   c |= 1; c cannot be zero.   We can at least put it back for multi-ranges. Added a new testcase to make sure EVRP is tracking it. bootstrapped on x86_64-pc-linux-gnu, no regressions.  pushed. Andrew commit

  1   2   3   4   5   6   7   >