* [PATCH] tree-optimization/105276 - Retain existing range knowledge when prefilling statements.
@ 2022-04-21 15:59 Andrew MacLeod
2022-04-22 5:51 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Andrew MacLeod @ 2022-04-21 15:59 UTC (permalink / raw)
To: gcc-patches, Richard Biener, Jakub Jelinek
[-- Attachment #1: Type: text/plain, Size: 504 bytes --]
When range_of_stmt was adjusted to avoid large recursion depth, I added
code to precalculate the dependencies without recursion.
This patch adjusted that pre-fill code to intersect the current known
range with the newly calculated one before setting the global range.
this Is what range_of_stmt does, and was missed.
Its running thru testing now, but I expect no issues with either
bootstrap nor testsuite regressions.
Do you want me to check this when testing is complete, or hold off?
Andrew
[-- Attachment #2: 105276.diff --]
[-- Type: text/x-patch, Size: 1854 bytes --]
commit 035a365988628794311c2d706d0e20e39c5fd261
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Thu Apr 21 11:10:30 2022 -0400
Retain existing range knowledge when prefilling statements.
When range_of_stmt was adjusted to avoid large recursion depth, we need to
intersect the calculated range whth the any known range to avoid losing
info. Range_of_stmt does this, but the new prefill code missed it.
PR tree-optimization/105276
gcc/
* gimple-range.cc (gimple_ranger::prefill_stmt_dependencies): Include
existing global range with calculated value.
gcc/testsuite/
* g++.dg/pr105276.C: New.
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index f41a989d617..f5e9e77bc71 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -389,6 +389,10 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
// Fold and save the value for NAME.
stmt = SSA_NAME_DEF_STMT (name);
fold_range_internal (r, stmt, name);
+ // Make sure we don't lose any current global info.
+ int_range_max tmp;
+ m_cache.get_global_range (tmp, name);
+ r.intersect (tmp);
m_cache.set_global_range (name, r);
}
continue;
diff --git a/gcc/testsuite/g++.dg/pr105276.C b/gcc/testsuite/g++.dg/pr105276.C
new file mode 100644
index 00000000000..ad0e9dd7e09
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr105276.C
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+bool
+foo(unsigned i)
+{
+ bool result = true;
+ while (i)
+ {
+ i = i % 3;
+ i = i - (i == 2 ? 2 : i ? 1 : 0);
+ result = !result;
+ }
+ return result;
+}
+
+/* We should be able to eliminate the i - operation. */
+/* { dg-final { scan-tree-dump-not "i_.* - " "optimized" } } */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tree-optimization/105276 - Retain existing range knowledge when prefilling statements.
2022-04-21 15:59 [PATCH] tree-optimization/105276 - Retain existing range knowledge when prefilling statements Andrew MacLeod
@ 2022-04-22 5:51 ` Richard Biener
2022-04-25 13:59 ` Andrew MacLeod
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2022-04-22 5:51 UTC (permalink / raw)
To: Andrew MacLeod; +Cc: gcc-patches, Jakub Jelinek
On Thu, Apr 21, 2022 at 5:59 PM Andrew MacLeod <amacleod@redhat.com> wrote:
>
> When range_of_stmt was adjusted to avoid large recursion depth, I added
> code to precalculate the dependencies without recursion.
>
> This patch adjusted that pre-fill code to intersect the current known
> range with the newly calculated one before setting the global range.
> this Is what range_of_stmt does, and was missed.
>
> Its running thru testing now, but I expect no issues with either
> bootstrap nor testsuite regressions.
>
> Do you want me to check this when testing is complete, or hold off?
OK if testing looks good.
Richard.
> Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tree-optimization/105276 - Retain existing range knowledge when prefilling statements.
2022-04-22 5:51 ` Richard Biener
@ 2022-04-25 13:59 ` Andrew MacLeod
0 siblings, 0 replies; 3+ messages in thread
From: Andrew MacLeod @ 2022-04-25 13:59 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, Jakub Jelinek
On 4/22/22 01:51, Richard Biener wrote:
> On Thu, Apr 21, 2022 at 5:59 PM Andrew MacLeod <amacleod@redhat.com> wrote:
>> When range_of_stmt was adjusted to avoid large recursion depth, I added
>> code to precalculate the dependencies without recursion.
>>
>> This patch adjusted that pre-fill code to intersect the current known
>> range with the newly calculated one before setting the global range.
>> this Is what range_of_stmt does, and was missed.
>>
>> Its running thru testing now, but I expect no issues with either
>> bootstrap nor testsuite regressions.
>>
>> Do you want me to check this when testing is complete, or hold off?
> OK if testing looks good.
>
> Richard.
>
passed everything fine. committed.
Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-25 14:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 15:59 [PATCH] tree-optimization/105276 - Retain existing range knowledge when prefilling statements Andrew MacLeod
2022-04-22 5:51 ` Richard Biener
2022-04-25 13:59 ` Andrew MacLeod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).