* [Patch] PR68137, drop constant overflow flag in adjust_range_with_scev when possible
@ 2015-11-23 11:08 Jiong Wang
2015-11-23 12:11 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jiong Wang @ 2015-11-23 11:08 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Biener
[-- Attachment #1: Type: text/plain, Size: 932 bytes --]
As reported by pr68137 and pr68326, r230150 caused new issues.
Those ICEs are caused by adjust_range_with_scev getting range with
overflowed constants min or max. So given there are too many places to
generate OVF, we do a check in adjust_range_with_scev, to drop OVF flag
when it's uncessary. This should fix the OVF side-effect caused by
r230150.
A simple regression testcase is included in this patch.
bootstrap OK on x86-64 and aarch64, regression ok on both.
For more background, please see discussion at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68317
OK for trunk?
2015-11-23 Richard Biener <rguenth@gcc.gnu.com>
Jiong Wang <jiong.wang@arm.com>
gcc/
PR tree-optimization/68137
PR tree-optimization/68326
* tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the
final min and max are not infinity.
gcc/testsuite/
* gcc.dg/pr68139.c: New testcase.
--
Regards,
Jiong
[-- Attachment #2: new.patch --]
[-- Type: text/x-patch, Size: 1266 bytes --]
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index e2393e4..8efeb76 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4331,6 +4331,17 @@ adjust_range_with_scev (value_range *vr, struct loop *loop,
&& is_positive_overflow_infinity (max)))
return;
+ /* Even for valid range info, sometimes overflow flag will leak in.
+ As GIMPLE IL should have no constants with TREE_OVERFLOW set, we
+ drop them except for +-overflow_infinity which still need special
+ handling in vrp pass. */
+ if (TREE_OVERFLOW_P (min)
+ && ! is_negative_overflow_infinity (min))
+ min = drop_tree_overflow (min);
+ if (TREE_OVERFLOW_P (max)
+ && ! is_positive_overflow_infinity (max))
+ max = drop_tree_overflow (max);
+
set_value_range (vr, VR_RANGE, min, max, vr->equiv);
}
diff --git a/gcc/testsuite/gcc.dg/pr68137.c b/gcc/testsuite/gcc.dg/pr68137.c
new file mode 100644
index 0000000..a30e1ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr68137.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void bar (int);
+
+void
+foo ()
+{
+ int index = 0;
+ for (index; index <= 10; index--)
+ /* Result of the following multiply will overflow
+ when converted to signed int. */
+ bar((0xcafe + index) * 0xdead);
+}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch] PR68137, drop constant overflow flag in adjust_range_with_scev when possible
2015-11-23 11:08 [Patch] PR68137, drop constant overflow flag in adjust_range_with_scev when possible Jiong Wang
@ 2015-11-23 12:11 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-11-23 12:11 UTC (permalink / raw)
To: Jiong Wang; +Cc: GCC Patches
On Mon, 23 Nov 2015, Jiong Wang wrote:
> As reported by pr68137 and pr68326, r230150 caused new issues.
>
> Those ICEs are caused by adjust_range_with_scev getting range with
> overflowed constants min or max. So given there are too many places to
> generate OVF, we do a check in adjust_range_with_scev, to drop OVF flag
> when it's uncessary. This should fix the OVF side-effect caused by
> r230150.
>
> A simple regression testcase is included in this patch.
>
> bootstrap OK on x86-64 and aarch64, regression ok on both.
>
> For more background, please see discussion at
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68317
>
> OK for trunk?
Ok.
Thanks,
Richard.
> 2015-11-23 Richard Biener <rguenth@gcc.gnu.com>
> Jiong Wang <jiong.wang@arm.com>
>
> gcc/
> PR tree-optimization/68137
> PR tree-optimization/68326
> * tree-vrp.c (adjust_range_with_scev): Call drop_tree_overflow if the
> final min and max are not infinity.
>
> gcc/testsuite/
> * gcc.dg/pr68139.c: New testcase.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-23 12:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-23 11:08 [Patch] PR68137, drop constant overflow flag in adjust_range_with_scev when possible Jiong Wang
2015-11-23 12:11 ` Richard Biener
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).