[COMMITTED] [frange] Revert relation handling in LTGT_EXPR.

2023-09-08 Thread Aldy Hernandez via Gcc-patches
In trying to come up with a missing testcase for commit 979e0fbf53cd, I've realized the patch doesn't catch anything. A relation of VREL_EQ in foperator_ltgt::fold_range() is either both arguments the same (x LTGT_EXPR x), which we should never emit, or two arguments that are actually the same,

[COMMITTED] [irange] Fix typo in contains_zero_p.

2023-09-07 Thread Aldy Hernandez via Gcc-patches
In the conversion of iranges to wide_int (commit cb779afeff204f), I mistakenly made contains_zero_p() return TRUE for undefined ranges. This means the rest of the patch was adjusted for this stupidity. For example, we ended up doing the following, to make up for the fact that contains_zero_p was

[COMMITTED] [frange] Handle relations in LTGT_EXPR.

2023-08-28 Thread Aldy Hernandez via Gcc-patches
LTGT_EXPR hasn't been handling relations, especially with NANs as a possibility. This handles them while documenting how relations work in a world with NANs. Basically we need to special case VREL_EQ before calling frelop_early_resolve. Note that VREL_EQ on entry to a range-op entry is really

[PATCH] [frange] Relax floating point relational folding.

2023-08-23 Thread Aldy Hernandez via Gcc-patches
[Jakub/Andrew: I've been staring at this for far too long and could use another pair of eyes.] This patch implements a new frelop_early_resolve() that handles the NAN special cases instead of calling into the integer version which can break for some combinations. Relaxing FP conditional folding

[COMMITTED] [frange] Return false if nothing changed in union_nans().

2023-08-21 Thread Aldy Hernandez via Gcc-patches
When one operand is a known NAN, we always return TRUE from union_nans(), even if no change occurred. This patch fixes the oversight. gcc/ChangeLog: * value-range.cc (frange::union_nans): Return false if nothing changed. (range_tests_floats): New test. ---

[COMMITTED] [irange] Return FALSE if updated bitmask is unchanged [PR110753]

2023-08-18 Thread Aldy Hernandez via Gcc-patches
The mask/value pair we track in the irange is a bit fickle in that it can sometimes contradict the bitmask inherent in the range. This can happen when a series of calculations yield a combination such as: [3, 1000] MASK 0xfffe VALUE 0x0 The mask/value above implies that the lowest

Re: [PATCH] Read global value/mask in IPA.

2023-08-03 Thread Aldy Hernandez via Gcc-patches
On 7/31/23 18:47, Martin Jambor wrote: Hello, On Tue, Jul 18 2023, Aldy Hernandez wrote: On 7/17/23 15:14, Aldy Hernandez wrote: Instead of reading the known zero bits in IPA, read the value/mask pair which is available. There is a slight change of behavior here. I have removed the check

Re: Fix profile upate after vectorizer peeling

2023-08-03 Thread Aldy Hernandez via Gcc-patches
On 8/3/23 16:29, Jeff Law wrote: On 8/3/23 08:23, Jan Hubicka wrote: Jeff, an help would be appreciated here :) I will try to debug this.  One option would be to disable branch prediciton on vect_check for time being - it is not inlined anyway Not a lot of insight.  The backwards threader

Re: [PATCH] Read global value/mask in IPA.

2023-07-31 Thread Aldy Hernandez via Gcc-patches
PING * 2 On Tue, Jul 25, 2023 at 8:32 AM Aldy Hernandez wrote: > > Ping > > On Mon, Jul 17, 2023, 15:14 Aldy Hernandez wrote: >> >> Instead of reading the known zero bits in IPA, read the value/mask >> pair which is available. >> >> There is a slight change of behavior here. I have removed the

[COMMITTED] [range-ops] Remove special case for handling bitmasks in casts.

2023-07-26 Thread Aldy Hernandez via Gcc-patches
Now that we can generically handle bitmasks for unary operators, there's no need to special case them. gcc/ChangeLog: * range-op-mixed.h (class operator_cast): Add update_bitmask. * range-op.cc (operator_cast::update_bitmask): New. (operator_cast::fold_range): Call

[COMMITTED] [range-ops] Handle bitmasks for ABSU_EXPR.

2023-07-26 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * range-op.cc (class operator_absu): Add update_bitmask. (operator_absu::update_bitmask): New. --- gcc/range-op.cc | 9 + 1 file changed, 9 insertions(+) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index bfab53caea0..5653ca0d186 100644 ---

[COMMITTED] [range-ops] Handle bitmasks for ABS_EXPR.

2023-07-26 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * range-op-mixed.h (class operator_abs): Add update_bitmask. * range-op.cc (operator_abs::update_bitmask): New. --- gcc/range-op-mixed.h | 2 ++ gcc/range-op.cc | 6 ++ 2 files changed, 8 insertions(+) diff --git a/gcc/range-op-mixed.h

[COMMITTED] [range-ops] Handle bitmasks for BIT_NOT_EXPR.

2023-07-26 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * range-op-mixed.h (class operator_bitwise_not): Add update_bitmask. * range-op.cc (operator_bitwise_not::update_bitmask): New. --- gcc/range-op-mixed.h | 2 ++ gcc/range-op.cc | 7 +++ 2 files changed, 9 insertions(+) diff --git a/gcc/range-op-mixed.h

[COMMITTED] [range-ops] Handle bitmasks for unary operators.

2023-07-26 Thread Aldy Hernandez via Gcc-patches
It looks like we missed out on bitmasks for unary operators because we were using bit_value_binop exclusively. This patch hands off to bit_value_unop when appropriate, thus allowing us to handle ABS and BIT_NOT_EXPR, and others. Follow-up patches will add the tweaks for the range-ops entries

Re: [PATCH] range-op-float: Fix up -frounding-math frange_arithmetic +- handling [PR110755]

2023-07-25 Thread Aldy Hernandez via Gcc-patches
The frange bits look fine to me, so if you feel confident in the math logic, go right ahead :). Thanks. Aldy On 7/24/23 18:01, Jakub Jelinek wrote: Hi! IEEE754 says that x + (-x) and x - x result in +0 in all rounding modes but rounding towards negative infinity, in which case the result is

[PATCH] Initialize value in bit_value_unop.

2023-07-25 Thread Aldy Hernandez via Gcc-patches
bit_value_binop initializes VAL regardless of the final mask. It even has a comment to that effect: /* Ensure that VAL is initialized (to any value). */ However, bit_value_unop, which in theory shares the same API, does not. This causes range-ops to choke on uninitialized VALs for some

[COMMITTED] Make some functions in CCP static.

2023-07-25 Thread Aldy Hernandez via Gcc-patches
Committed as obvious. gcc/ChangeLog: * tree-ssa-ccp.cc (value_mask_to_min_max): Make static. (bit_value_mult_const): Same. (get_individual_bits): Same. --- gcc/tree-ssa-ccp.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-ccp.cc

Re: [PATCH] Read global value/mask in IPA.

2023-07-25 Thread Aldy Hernandez via Gcc-patches
Ping On Mon, Jul 17, 2023, 15:14 Aldy Hernandez wrote: > Instead of reading the known zero bits in IPA, read the value/mask > pair which is available. > > There is a slight change of behavior here. I have removed the check > for SSA_NAME, as the ranger can calculate the range and value/mask

Re: [PATCH] Read global value/mask in IPA.

2023-07-18 Thread Aldy Hernandez via Gcc-patches
On 7/17/23 15:14, Aldy Hernandez wrote: Instead of reading the known zero bits in IPA, read the value/mask pair which is available. There is a slight change of behavior here. I have removed the check for SSA_NAME, as the ranger can calculate the range and value/mask for INTEGER_CST. This

[PATCH] Read global value/mask in IPA.

2023-07-17 Thread Aldy Hernandez via Gcc-patches
Instead of reading the known zero bits in IPA, read the value/mask pair which is available. There is a slight change of behavior here. I have removed the check for SSA_NAME, as the ranger can calculate the range and value/mask for INTEGER_CST. This simplifies the code a bit, since there's no

[PATCH] Export value/mask known bits from IPA.

2023-07-17 Thread Aldy Hernandez via Gcc-patches
Currently IPA throws away the known 1 bits because VRP and irange have traditionally only had a way of tracking known 0s (set_nonzero_bits). With the ability to keep all the known bits in the irange, we can now save this between passes. OK? gcc/ChangeLog: * ipa-prop.cc

[PATCH] Export value/mask known bits from CCP.

2023-07-17 Thread Aldy Hernandez via Gcc-patches
Currently CCP throws away the known 1 bits because VRP and irange have traditionally only had a way of tracking known 0s (set_nonzero_bits). With the ability to keep all the known bits in the irange, we can now save this between passes. OK? gcc/ChangeLog: * tree-ssa-ccp.cc

[COMMITTED] Normalize irange_bitmask before union/intersect.

2023-07-17 Thread Aldy Hernandez via Gcc-patches
The bit twiddling in union/intersect for the value/mask pair must be normalized to have the unknown bits with a value of 0 in order to make the math simpler. Normalizing at construction slowed VRP by 1.5% so I opted to normalize before updating the bitmask in range-ops, since it was the only

[COMMITTED] Add global setter for value/mask pair for SSA names.

2023-07-17 Thread Aldy Hernandez via Gcc-patches
This patch provides a way to set the value/mask pair of known bits globally, similarly to how we can use set_nonzero_bits for known 0 bits. This can then be used by CCP and IPA to set value/mask info instead of throwing away the known 1 bits. In further clean-ups, I will see if it makes sense to

Re: [PATCH V4] Optimize '(X - N * M) / N' to 'X / N - M' if valid

2023-07-14 Thread Aldy Hernandez via Gcc-patches
On 7/14/23 15:37, Richard Biener wrote: On Fri, 14 Jul 2023, Aldy Hernandez wrote: I don't know what you're trying to accomplish here, as I haven't been following the PR, but adding all these helper functions to the ranger header file seems wrong, especially since there's only one use of

Re: [PATCH V4] Optimize '(X - N * M) / N' to 'X / N - M' if valid

2023-07-14 Thread Aldy Hernandez via Gcc-patches
I don't know what you're trying to accomplish here, as I haven't been following the PR, but adding all these helper functions to the ranger header file seems wrong, especially since there's only one use of them. I see you're tweaking the irange API, adding helper functions to range-op (which

Re: [COMMITTED] [range-op] Take known set bits into account in popcount [PR107053]

2023-07-14 Thread Aldy Hernandez via Gcc-patches
On 7/12/23 23:50, Jeff Law wrote: On 7/12/23 15:15, Aldy Hernandez via Gcc-patches wrote: This patch teaches popcount about known set bits which are now available in the irange. PR tree-optimization/107053 gcc/ChangeLog: * gimple-range-op.cc (cfn_popcount): Use known set bits

[COMMITTED] [range-op] Take known set bits into account in popcount [PR107053]

2023-07-12 Thread Aldy Hernandez via Gcc-patches
This patch teaches popcount about known set bits which are now available in the irange. PR tree-optimization/107053 gcc/ChangeLog: * gimple-range-op.cc (cfn_popcount): Use known set bits. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107053.c: New test. ---

[COMMITTED] [range-op] Take known mask into account for bitwise ands [PR107043]

2023-07-12 Thread Aldy Hernandez via Gcc-patches
PR tree-optimization/107043 gcc/ChangeLog: * range-op.cc (operator_bitwise_and::op1_range): Update bitmask. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr107043.c: New test. --- gcc/range-op.cc | 8

[COMMITTED] [range-op] Enable value/mask propagation in range-op.

2023-07-12 Thread Aldy Hernandez via Gcc-patches
Throw the switch in range-ops to make full use of the value/mask information instead of only the nonzero bits. This will cause most of the operators implemented in range-ops to use the value/mask information calculated by CCP's bit_value_binop() function which range-ops uses. This opens up more

[COMMITTED] Implement value/mask tracking for irange.

2023-07-07 Thread Aldy Hernandez via Gcc-patches
Integer ranges (irange) currently track known 0 bits. We've wanted to track known 1 bits for some time, and instead of tracking known 0 and known 1's separately, it has been suggested we track a value/mask pair similarly to what we do for CCP and RTL. This patch implements such a thing. With

[COMMITTED] The caller to irange::intersect (wide_int, wide_int) must normalize the range.

2023-07-07 Thread Aldy Hernandez via Gcc-patches
Per the function comment, the caller to intersect(wide_int, wide_int) must handle the mask. This means it must also normalize the range if anything changed. gcc/ChangeLog: * value-range.cc (irange::intersect): Leave normalization to caller. --- gcc/value-range.cc | 7 +-- 1

[COMMITTED] A singleton irange has all known bits.

2023-07-07 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.cc (irange::get_bitmask_from_range): Return all the known bits for a singleton. (irange::set_range_from_bitmask): Set a range of a singleton when all bits are known. --- gcc/value-range.cc | 19 ++- 1 file changed, 18

[COMMITTED] Tidy up the range normalization code.

2023-06-29 Thread Aldy Hernandez via Gcc-patches
There's a few spots where a range is being altered in-place, but we fail to call normalize the range. This patch makes sure we always call normalize_kind(), and that normalize_kind in turn, calls verify_range to make sure verything is canonical. gcc/ChangeLog: * value-range.cc

[COMMITTED] Move maybe_set_nonzero_bits() to its only user.

2023-06-29 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * tree-vrp.cc (maybe_set_nonzero_bits): Move from here... * tree-ssa-dom.cc (maybe_set_nonzero_bits): ...to here. * tree-vrp.h (maybe_set_nonzero_bits): Remove. --- gcc/tree-ssa-dom.cc | 65 + gcc/tree-vrp.cc

Re: [PATCH] Implement ipa_vr hashing.

2023-06-26 Thread Aldy Hernandez via Gcc-patches
ng*2 > > > > On Wed, Jun 14, 2023, 14:11 Aldy Hernandez wrote: > >> > >> PING > >> > >> On Sat, Jun 10, 2023 at 10:30 PM Aldy Hernandez wrote: > >> > > >> > > >> > > >> > On 5/29/23 16:51, Martin Jam

Re: [PATCH] Implement ipa_vr hashing.

2023-06-26 Thread Aldy Hernandez via Gcc-patches
5/29/23 16:51, Martin Jambor wrote: >> > > Hi, >> > > >> > > On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote: >> > >> Implement hashing for ipa_vr. When all is said and done, all these >> > >> patches incurr a 7.64% slowdo

Re: [PATCH] Implement ipa_vr hashing.

2023-06-21 Thread Aldy Hernandez via Gcc-patches
Ping*2 On Wed, Jun 14, 2023, 14:11 Aldy Hernandez wrote: > PING > > On Sat, Jun 10, 2023 at 10:30 PM Aldy Hernandez wrote: > > > > > > > > On 5/29/23 16:51, Martin Jambor wrote: > > > Hi, > > > > > > On Mon, May 22 2023, Aldy Hernande

Re: [PATCH] Convert ipa_jump_func to use ipa_vr instead of a value_range.

2023-06-21 Thread Aldy Hernandez via Gcc-patches
Ping*2 On Wed, Jun 14, 2023, 14:09 Aldy Hernandez wrote: > PING > > On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez wrote: > > > > This patch converts the ipa_jump_func code to use the type agnostic > > ipa_vr suitable for GC instead of value_range which is integer specific. > > > > I've

Re: [PATCH] Convert remaining uses of value_range in ipa-*.cc to Value_Range.

2023-06-21 Thread Aldy Hernandez via Gcc-patches
Ping*2 On Wed, Jun 14, 2023, 14:10 Aldy Hernandez wrote: > PING > > On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez wrote: > > > > Minor cleanups to get rid of value_range in IPA. There's only one left, > > but it's in the switch code which is integer specific. > > > > OK? > > > >

Re: [PATCH] Implement ipa_vr hashing.

2023-06-14 Thread Aldy Hernandez via Gcc-patches
PING On Sat, Jun 10, 2023 at 10:30 PM Aldy Hernandez wrote: > > > > On 5/29/23 16:51, Martin Jambor wrote: > > Hi, > > > > On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote: > >> Implement hashing for ipa_vr. When all is said and done, all the

Re: [PATCH] Convert remaining uses of value_range in ipa-*.cc to Value_Range.

2023-06-14 Thread Aldy Hernandez via Gcc-patches
PING On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez wrote: > > Minor cleanups to get rid of value_range in IPA. There's only one left, > but it's in the switch code which is integer specific. > > OK? > > gcc/ChangeLog: > > * ipa-cp.cc (decide_whether_version_node): Adjust comment. >

Re: [PATCH] Convert ipa_jump_func to use ipa_vr instead of a value_range.

2023-06-14 Thread Aldy Hernandez via Gcc-patches
PING On Mon, May 22, 2023 at 8:56 PM Aldy Hernandez wrote: > > This patch converts the ipa_jump_func code to use the type agnostic > ipa_vr suitable for GC instead of value_range which is integer specific. > > I've disabled the range cacheing to simplify the patch for review, but > it is handled

Re: [PATCH] Implement ipa_vr hashing.

2023-06-10 Thread Aldy Hernandez via Gcc-patches
On 5/29/23 16:51, Martin Jambor wrote: Hi, On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote: Implement hashing for ipa_vr. When all is said and done, all these patches incurr a 7.64% slowdown for ipa-cp, with is entirely covered by the similar 7% increase in this area last week

Re: [PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-06-10 Thread Aldy Hernandez via Gcc-patches
On 6/10/23 10:49, Martin Jambor wrote: Hi, thanks for dealing with my requests. On Wed, Jun 07 2023, Aldy Hernandez wrote: On 5/26/23 18:17, Martin Jambor wrote: Hello, On Mon, May 22 2023, Aldy Hernandez wrote: I've adjusted the patch with some minor cleanups that came up when I

Re: [COMMITTED 2/4] - Remove tree_code from range-operator.

2023-06-09 Thread Aldy Hernandez via Gcc-patches
On 6/8/23 20:57, Andrew MacLeod wrote: Range_operator had a tree code added last release to facilitate bitmask operations.  This was intended to be a temporary change until we could figure out something more strategic going forward. This patch removes the tree_code and replaces it with a

Re: [PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-06-07 Thread Aldy Hernandez via Gcc-patches
On 5/26/23 18:17, Martin Jambor wrote: Hello, On Mon, May 22 2023, Aldy Hernandez wrote: I've adjusted the patch with some minor cleanups that came up when I implemented the rest of the IPA revamp. Rested. OK? On Wed, May 17, 2023 at 4:31 PM Aldy Hernandez wrote: This converts the

Re: [PATCH] Implement ipa_vr hashing.

2023-06-07 Thread Aldy Hernandez via Gcc-patches
On 5/29/23 16:51, Martin Jambor wrote: Hi, On Mon, May 22 2023, Aldy Hernandez via Gcc-patches wrote: Implement hashing for ipa_vr. When all is said and done, all these patches incurr a 7.64% slowdown for ipa-cp, with is entirely covered by the similar 7% increase in this area last week

Re: [PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-06-06 Thread Aldy Hernandez via Gcc-patches
My apologies for the delay. I was on vacation. On 5/26/23 18:17, Martin Jambor wrote: Hello, On Mon, May 22 2023, Aldy Hernandez wrote: I've adjusted the patch with some minor cleanups that came up when I implemented the rest of the IPA revamp. Rested. OK? On Wed, May 17, 2023 at 4:31 PM

Re: [COMMITTED 4/4] - Gimple range PHI analyzer and testcases

2023-05-25 Thread Aldy Hernandez via Gcc-patches
Some minor nits. +// There can be only one running at a time. +static phi_analyzer *phi_analysis_object = NULL; Shouldn't this be phi_analyzer_object to be more consistent? Similarly throughout. +// Create a new phi_group with members BM, initialvalue INIT_VAL, modifier +// statement

[COMMITTED] Stream out NANs correctly.

2023-05-24 Thread Aldy Hernandez via Gcc-patches
NANs don't have bounds, so there's no need to stream them out. gcc/ChangeLog: * data-streamer-in.cc (streamer_read_value_range): Handle NANs. * data-streamer-out.cc (streamer_write_vrange): Same. * value-range.h (class vrange): Make streamer_write_vrange a friend. ---

[COMMITTED] Disallow setting of NANs in frange setter unless setting trees.

2023-05-24 Thread Aldy Hernandez via Gcc-patches
frange::set() is confusing in that we can set a NAN by specifying a bound of +-NAN, even though we tecnically disallow NANs in the setter because the kind can never be VR_NAN. This is a wart for get_tree_range(), which builds a range out of a tree from the source, to work correctly. It's ugly,

[COMMITTED] Hash known NANs correctly for franges.

2023-05-24 Thread Aldy Hernandez via Gcc-patches
We're ICEing when trying to hash a known NAN. This is unnoticeable because the only user would be IPA, and even so, it currently doesn't handle floats. However, handling floats is a flip of a switch, so it's best to handle them already. gcc/ChangeLog: * value-range.cc (add_vrange):

[COMMITTED] Add an frange::set_nan() variant that takes a nan_state.

2023-05-24 Thread Aldy Hernandez via Gcc-patches
Generalize frange::set_nan() to take a nan_state and make current set_nan() methods syntactic sugar. This is in preparation for better streaming of NANs for LTO/IPA. gcc/ChangeLog: * value-range.h (frange::set_nan): New. --- gcc/value-range.h | 32 +--- 1

[COMMITTED] Remove deprecated vrange::kind().

2023-05-24 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.h (vrange::kind): Remove. --- gcc/value-range.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 936eb175062..b8cc2a0e76a 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -100,9 +100,6 @@ public:

Re: [COMMITTED] Remove buggy special case in irange::invert [PR109934].

2023-05-23 Thread Aldy Hernandez via Gcc-patches
BTW, we should probably backport this to god knows how many branches. Aldy On Tue, May 23, 2023 at 2:58 PM Aldy Hernandez wrote: > > [Andrew, do you remotely remember what if anything this did? It came > from a wholesale merge from our long forgotten branch, so there's no > history on the

[COMMITTED] Remove buggy special case in irange::invert [PR109934].

2023-05-23 Thread Aldy Hernandez via Gcc-patches
[Andrew, do you remotely remember what if anything this did? It came from a wholesale merge from our long forgotten branch, so there's no history on the specifics of it. Not important, I'm just curious. It was probably me high on something.] This patch removes a buggy special case in

[COMMITTED] Use delete[] in int_range destructor [PR109920]

2023-05-23 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: PR tree-optimization/109920 * value-range.h (RESIZABLE>::~int_range): Use delete[]. --- gcc/value-range.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 171e6426c6e..936eb175062 100644 ---

[PATCH] Convert remaining uses of value_range in ipa-*.cc to Value_Range.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
Minor cleanups to get rid of value_range in IPA. There's only one left, but it's in the switch code which is integer specific. OK? gcc/ChangeLog: * ipa-cp.cc (decide_whether_version_node): Adjust comment. * ipa-fnsummary.cc (evaluate_conditions_for_known_args): Adjust

[PATCH] Implement ipa_vr hashing.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
Implement hashing for ipa_vr. When all is said and done, all these patches incurr a 7.64% slowdown for ipa-cp, with is entirely covered by the similar 7% increase in this area last week. So we get type agnostic ranges with "infinite" range precision close to free. There is no change in overall

[PATCH] Convert ipa_jump_func to use ipa_vr instead of a value_range.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
This patch converts the ipa_jump_func code to use the type agnostic ipa_vr suitable for GC instead of value_range which is integer specific. I've disabled the range cacheing to simplify the patch for review, but it is handled in the next patch in the series. OK? gcc/ChangeLog: *

Re: [PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
I've adjusted the patch with some minor cleanups that came up when I implemented the rest of the IPA revamp. Rested. OK? On Wed, May 17, 2023 at 4:31 PM Aldy Hernandez wrote: > > This converts the lattice to store ranges in Value_Range instead of > value_range (*) to make it type agnostic, and

Re: [PATCH] Provide an API for ipa_vr.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
I've adjusted the patch with some minor cleanups that came up when I implemented the rest of the IPA revamp. Retested. OK? On Wed, May 17, 2023 at 4:16 PM Aldy Hernandez wrote: > > This patch encapsulates the ipa_vr internals into an API. It also > makes it type agnostic, in preparation for

[COMMITTED] Implement some miscellaneous zero accessors for Value_Range.

2023-05-22 Thread Aldy Hernandez via Gcc-patches
This adds some missing accessors to the type agnostic Value_Range class. They'll be used in the upcoming IPA work. gcc/ChangeLog: * value-range.h (class Value_Range): Implement set_zero, set_nonzero, and nonzero_p. --- gcc/value-range.h | 3 +++ 1 file changed, 3 insertions(+)

Re: [PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
On 5/17/23 16:30, Aldy Hernandez wrote: This converts the lattice to store ranges in Value_Range instead of value_range (*) to make it type agnostic, and adjust all users accordingly. I think it is a good example on converting from static ranges to more general, type agnostic ones. I've

[PATCH] Convert ipcp_vr_lattice to type agnostic framework.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
This converts the lattice to store ranges in Value_Range instead of value_range (*) to make it type agnostic, and adjust all users accordingly. I think it is a good example on converting from static ranges to more general, type agnostic ones. I've been careful to make sure Value_Range never ends

[PATCH] Provide an API for ipa_vr.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
This patch encapsulates the ipa_vr internals into an API. It also makes it type agnostic, in preparation for upcoming changes to IPA. Interestingly, there's a 0.44% improvement to IPA-cp, which I'm sure we'll soak up with future changes in this area :). BTW, there's a note here: + //

[COMMITTED] Add Value_Range::operator=.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.h (Value_Range::operator=): New. --- gcc/value-range.h | 25 + 1 file changed, 25 insertions(+) diff --git a/gcc/value-range.h b/gcc/value-range.h index ab982d18402..af81d6080da 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h

[COMMITTED] Provide support for copying unsupported ranges.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
The unsupported_range class is provided for completness sake. It is a way to set VARYING/UNDEFINED ranges for unsupported ranges (currently anything not float, integer, or pointer). You can't do anything with them, except set_varying, and set_undefined. We will trap on any other operation.

Re: [PATCH] Add support for vrange streaming.

2023-05-17 Thread Aldy Hernandez via Gcc-patches
I'm pushing this in preparation for further changes in this area later today. Aldy On Thu, Apr 27, 2023 at 1:36 PM Aldy Hernandez wrote: > > Thanks. I will put it aside until I start posting the IPA patches. > > Aldy > > On Thu, Apr 27, 2023, 13:02 Richard Biener wrote: >> >> On Tue, Apr 18,

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-16 Thread Aldy Hernandez via Gcc-patches
On 5/15/23 20:14, Aldy Hernandez wrote: On 5/15/23 17:07, Aldy Hernandez wrote: On 5/15/23 12:42, Jakub Jelinek wrote: On Mon, May 15, 2023 at 12:35:23PM +0200, Aldy Hernandez wrote: gcc/ChangeLog: PR tree-optimization/109695 * value-range.cc (irange::operator=): Resize range.    

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On 5/15/23 17:07, Aldy Hernandez wrote: On 5/15/23 12:42, Jakub Jelinek wrote: On Mon, May 15, 2023 at 12:35:23PM +0200, Aldy Hernandez wrote: gcc/ChangeLog: PR tree-optimization/109695 * value-range.cc (irange::operator=): Resize range. (irange::union_): Same.

Re: [COMMITTED] Remove deprecated range_fold_{unary, binary}_expr uses from ipa-*.

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On 5/5/23 17:10, Martin Jambor wrote: Hello, On Wed, Apr 26 2023, Aldy Hernandez via Gcc-patches wrote: gcc/ChangeLog: * ipa-cp.cc (ipa_vr_operation_and_type_effects): Convert to ranger API. (ipa_value_range_from_jfunc): Same. (propagate_vr_across_jump_function

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On Mon, May 15, 2023 at 5:03 PM Aldy Hernandez wrote: > > > > On 5/15/23 13:08, Richard Biener wrote: > > On Mon, May 15, 2023 at 12:35 PM Aldy Hernandez wrote: > >> > >> > >> We can now have int_range for automatically > >> resizable ranges. int_range_max is now int_range<3, true> > >> for a

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On 5/15/23 12:42, Jakub Jelinek wrote: On Mon, May 15, 2023 at 12:35:23PM +0200, Aldy Hernandez wrote: gcc/ChangeLog: PR tree-optimization/109695 * value-range.cc (irange::operator=): Resize range. (irange::union_): Same. (irange::intersect): Same.

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On 5/15/23 13:08, Richard Biener wrote: On Mon, May 15, 2023 at 12:35 PM Aldy Hernandez wrote: We can now have int_range for automatically resizable ranges. int_range_max is now int_range<3, true> for a 69X reduction in size from current trunk, and 6.9X reduction from GCC12. This incurs

Re: [PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
On 5/15/23 16:24, Bernhard Reutner-Fischer wrote: On Mon, 15 May 2023 12:35:23 +0200 Aldy Hernandez via Gcc-patches wrote: +// For resizable ranges, resize the range up to HARD_MAX_RANGES if the +// NEEDED pairs is greater than the current capacity of the range. + +inline void +irange

[PATCH] Add auto-resizing capability to irange's [PR109695]

2023-05-15 Thread Aldy Hernandez via Gcc-patches
We can now have int_range for automatically resizable ranges. int_range_max is now int_range<3, true> for a 69X reduction in size from current trunk, and 6.9X reduction from GCC12. This incurs a 5% performance penalty for VRP that is more than covered by our > 13% improvements recently.

Re: [COMMITTED] Remove deprecated range_fold_{unary, binary}_expr uses from ipa-*.

2023-05-11 Thread Aldy Hernandez via Gcc-patches
On 5/5/23 17:10, Martin Jambor wrote: Hello, On Wed, Apr 26 2023, Aldy Hernandez via Gcc-patches wrote: gcc/ChangeLog: * ipa-cp.cc (ipa_vr_operation_and_type_effects): Convert to ranger API. (ipa_value_range_from_jfunc): Same. (propagate_vr_across_jump_function

Re: [PATCH] Remove type from vrange_storage::equal_p.

2023-05-05 Thread Aldy Hernandez via Gcc-patches
On 5/3/23 13:41, Aldy Hernandez wrote: [Andrew, since you suggested this, is this what you had in mind?]. Pushed. You can comment when you're back from vacation :). Aldy The equal_p method in vrange_storage is only used to compare ranges that are the same type. No sense passing the type

Re: [PATCH] gimple-range-op: Improve handling of sin/cos ranges

2023-05-05 Thread Aldy Hernandez via Gcc-patches
On 5/5/23 22:53, Jakub Jelinek wrote: Hi! Similarly to the earlier sqrt patch, this patch attempts to improve sin/cos ranges. As the functions are periodic, for the reverse range there is not much we can do (but I've discovered I forgot to take into account the boundary ulps for the

Re: [PATCH] gimple-range-op: Improve handling of sqrt ranges

2023-05-05 Thread Aldy Hernandez via Gcc-patches
On Fri, May 5, 2023 at 11:14 AM Jakub Jelinek wrote: > > On Fri, May 05, 2023 at 11:06:31AM +0200, Aldy Hernandez wrote: > > > +/* Compute FUNC (ARG) where FUNC is a mpfr function. If RES_LOW is > > > non-NULL, > > > + set it to low bound of possible range if the function is expected to > >

Re: [PATCH] gimple-range-op: Improve handling of sqrt ranges

2023-05-05 Thread Aldy Hernandez via Gcc-patches
On 5/5/23 10:00, Jakub Jelinek wrote: Hi! The previous patch just added basic intrinsic ranges for sqrt ([-0.0, +Inf] +-NAN being the general result range of the function and [-0.0, +Inf] the general operand range if result isn't NAN etc.), the following patch intersects those ranges with

[COMMITTED] Allow varying ranges of unknown types in irange::verify_range [PR109711]

2023-05-03 Thread Aldy Hernandez via Gcc-patches
The old legacy code allowed building ranges of unknown types so passes like IPA could build and propagate VARYING. For now it's easiest to allow the old behavior, it's not like you can do anything with these ranges except build them and copy them. Eventually we should convert all users of

[PATCH] Remove type from vrange_storage::equal_p.

2023-05-03 Thread Aldy Hernandez via Gcc-patches
[Andrew, since you suggested this, is this what you had in mind?]. The equal_p method in vrange_storage is only used to compare ranges that are the same type. No sense passing the type if it can be determined from the range being compared. gcc/ChangeLog: * gimple-range-cache.cc

Re: [PATCH (pushed)] clang warning: warning: private field 'm_gc' is not used [-Wunused-private-field]

2023-05-03 Thread Aldy Hernandez via Gcc-patches
Thanks. On Wed, May 3, 2023, 11:17 Martin Liška wrote: > Pushed to master as obvious. > > Martin > > PR tree-optimization/109693 > > gcc/ChangeLog: > > * value-range-storage.cc (vrange_allocator::vrange_allocator): > Remove unused field. > *

[COMMITTED] Remove unused friends in int_range<>.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.h (class int_range): Remove gt_ggc_mx and gt_pch_nx friends. --- gcc/value-range.h | 5 - 1 file changed, 5 deletions(-) diff --git a/gcc/value-range.h b/gcc/value-range.h index 5cff50e6d03..ab8d7d3c5dc 100644 --- a/gcc/value-range.h +++

[COMMITTED] Conversion to irange wide_int API.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
This converts the irange API to use wide_ints exclusively, along with its users. This patch will slow down VRP, as there will be more useless wide_int to tree conversions. However, this slowdown is only temporary, as a follow-up patch will convert the internal representation of iranges to

[COMMITTED] Inline irange::set_nonzero.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
irange::set_nonzero is used everywhere and benefits immensely from inlining. gcc/ChangeLog: * value-range.h (irange::set_nonzero): Inline. --- gcc/value-range.h | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/value-range.h

[COMMITTED] Rewrite bounds_of_var_in_loop() to use ranges.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
Little by little, bounds_of_var_in_loop() has grown into an unmaintainable mess. This patch rewrites the code to use the relevant APIs as well as refactor it to make it more readable. gcc/ChangeLog: * gimple-range-fold.cc (tree_lower_bound): Delete. (tree_upper_bound): Delete.

[COMMITTED] Convert get_legacy_range in bounds_of_var_in_loop to irange API.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * vr-values.cc (bounds_of_var_in_loop): Convert to irange API. --- gcc/vr-values.cc | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 7f623102ac6..3d28198f9f5 100644 --- a/gcc/vr-values.cc +++

[COMMITTED] Convert internal representation of irange to wide_ints.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * range-op.cc (update_known_bitmask): Adjust for irange containing wide_ints internally. * tree-ssanames.cc (set_nonzero_bits): Same. * tree-ssanames.h (set_nonzero_bits): Same. * value-range-storage.cc (irange_storage::set_irange): Same.

[COMMITTED] Merge irange::union/intersect into irange_union/intersect.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.cc (irange::irange_union): Rename to... (irange::union_): ...this. (irange::irange_intersect): Rename to... (irange::intersect): ...this. * value-range.h (irange::union_): Delete. (irange::intersect): Delete. ---

[COMMITTED] Replace vrp_val* with wide_ints.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
This patch removes all uses of vrp_val_{min,max} in favor for a irange_val_* which are wide_int based. This will leave only one use of vrp_val_* which returns trees in range_of_ssa_name_with_loop_info() because it needs to work with non-integers (floats, etc). In a follow-up patch, this function

[COMMITTED] Cleanup irange::set.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
Now that anti-ranges are no more and iranges contain wide_ints instead of trees, various cleanups are possible. This is one of a handful of patches improving the performance of irange::set() which is not on a hot path, but quite sensitive because it is so pervasive. gcc/ChangeLog: *

[COMMITTED] vrange_storage overhaul

2023-05-01 Thread Aldy Hernandez via Gcc-patches
[tl;dr: This is a rewrite of value-range-storage.* such that global ranges and the internal ranger cache can use the same efficient storage mechanism. It is optimized such that when wide_ints are dropped into irange, the copying back and forth from storage will be very fast, while being able to

[COMMITTED] Various cleanups in vr-values.cc towards ranger API.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * vr-values.cc (check_for_binary_op_overflow): Tidy up by using ranger API. (compare_ranges): Delete. (compare_range_with_value): Delete. (bounds_of_var_in_loop): Tidy up by using ranger API.

[COMMITTED] Remove irange::{min,max,kind}.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * tree-ssa-loop-niter.cc (refine_value_range_using_guard): Remove kind() call. (determine_value_range): Same. (record_nonwrapping_iv): Same. (infer_loop_bounds_from_signedness): Same. (scev_var_range_cant_overflow): Same. *

[COMMITTED] Remove irange::tree_{lower,upper}_bound.

2023-05-01 Thread Aldy Hernandez via Gcc-patches
gcc/ChangeLog: * value-range.cc (irange::irange_set_anti_range): Remove uses of tree_lower_bound and tree_upper_bound. (irange::verify_range): Same. (irange::operator==): Same. (irange::singleton_p): Same. * value-range.h (irange::tree_lower_bound):

Re: [PATCH] gimple-range-op: Handle sqrt (basic bounds only)

2023-04-27 Thread Aldy Hernandez via Gcc-patches
Ok On Thu, Apr 27, 2023, 15:30 Jakub Jelinek wrote: > Hi! > > The following patch adds sqrt support (but similarly to sincos, only > dumb basic ranges only). > > Ok for trunk if it passes bootstrap/regtest? > > Will improve this incrementally and sin/cos as well. > > 2023-04-27 Jakub Jelinek

  1   2   3   4   5   6   7   8   9   10   >