public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6559] Allow more precision when querying from fold_const.
@ 2022-01-13 18:52 Andrew Macleod
0 siblings, 0 replies; only message in thread
From: Andrew Macleod @ 2022-01-13 18:52 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:49d5fb4feee831868d80fff4d024c271911c92ca
commit r12-6559-g49d5fb4feee831868d80fff4d024c271911c92ca
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Wed Jan 12 13:31:08 2022 -0500
Allow more precision when querying from fold_const.
fold_const::expr_not_equal_to queries for a current range, but still uses
the old value_range class. This is causing it to miss opportunities when
ranger can provide something better.
PR tree-optimization/83072
PR tree-optimization/83073
PR tree-optimization/97909
gcc/
* fold-const.c (expr_not_equal_to): Use a multi-range class.
gcc/testsuite/
* gcc.dg/pr83072-2.c: New.
* gcc.dg/pr83073.c: New.
Diff:
---
gcc/fold-const.c | 2 +-
gcc/testsuite/gcc.dg/pr83072-2.c | 18 ++++++++++++++++++
gcc/testsuite/gcc.dg/pr83073.c | 10 ++++++++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 397fa9a03a1..cd540e1f2b3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -10734,7 +10734,7 @@ tree_expr_nonzero_p (tree t)
bool
expr_not_equal_to (tree t, const wide_int &w)
{
- value_range vr;
+ int_range_max vr;
switch (TREE_CODE (t))
{
case INTEGER_CST:
diff --git a/gcc/testsuite/gcc.dg/pr83072-2.c b/gcc/testsuite/gcc.dg/pr83072-2.c
new file mode 100644
index 00000000000..f495f2582c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83072-2.c
@@ -0,0 +1,18 @@
+/* { dg-do compile} */
+/* { dg-options "-O2 -fdump-tree-evrp-details" } */
+
+int f1(int a, int b, int c){
+ if(c==0)__builtin_unreachable();
+ a *= c;
+ b *= c;
+ return a == b;
+}
+
+int f2(int a, int b, int c){
+ c |= 1;
+ a *= c;
+ b *= c;
+ return a == b;
+}
+
+/* { dg-final { scan-tree-dump-times "gimple_simplified to" 2 "evrp" } } */
diff --git a/gcc/testsuite/gcc.dg/pr83073.c b/gcc/testsuite/gcc.dg/pr83073.c
new file mode 100644
index 00000000000..1168ae822a4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr83073.c
@@ -0,0 +1,10 @@
+/* { dg-do compile} */
+/* { dg-options "-O2 -fdump-tree-evrp-details -fno-tree-fre -fno-tree-ccp -fno-tree-forwprop" } */
+
+int f(int x)
+{
+ x = x|1;
+ return x & 1;
+}
+
+/* { dg-final { scan-tree-dump "gimple_simplified to.* = 1" "evrp" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-13 18:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-13 18:52 [gcc r12-6559] Allow more precision when querying from fold_const 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).