public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] Make ranger the vrp1 default.
@ 2022-11-01 13:58 Andrew MacLeod
  0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2022-11-01 13:58 UTC (permalink / raw)
  To: gcc-patches; +Cc: hernandez, aldy, Richard Biener, Jakub Jelinek, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 1760 bytes --]

This patch turns ranger on by default for the VRP1 pass.

I needed to adjust gcc.dg/pr68217.c to scan for a better range ([-INF, 
-INF][0, 0]) than the original [-INF, 0] it was looking for.

This also triggers the new __builtin_unreachable code in the ranger VRP 
pass, so I added a new testcase to show accumulated unreachables are 
combined properly.  tree-ssa/pr107009.c also verifies that a 
non-dominated unreachable call doesn't incorrectly affect the global range.

Bootstrapped on x86_64-pc-linux-gnu with no regressions*. Pushed.

* OK. no regressions is debatable.  I've been seeing the following 
spurious failure for the past few weeks.  Ranger made them pass for a 
while, then made them fail, so Ive been ignoring them. I took a quick 
look.  Basically, we optimize away an unnecessary statement feeding a 
condition based on a combination of what ranger calculates and results 
from loop analysis.  (The statement is not referenced in any debug 
statement).  That later causes a PHI to no longer been needed, and DCE2 
removed the PHI and some other stuff, which then causes the debug_stmt 
to lose its reference.  /blame dce2 :-)

< FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 x == 10 - i
< FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 y == 20 - 2 * i
< FAIL: gcc.dg/guality/pr54693-2.c   -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  -DPREVENT_OPTIMIZATION line 21 z == 30 - 3 * i

I choose to ignore this for now...  I want to get VRP1 turned to ranger 
by default and see if any issues show up.  I believe this removes the 
last remaining use of legacy vrp.

Andrew

[-- Attachment #2: 0004 --]
[-- Type: text/plain, Size: 2787 bytes --]

commit e7310e24b1c0ca67b1bb507c1330b2bf39e59e32
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Tue Oct 25 16:42:41 2022 -0400

    Make ranger vrp1 default.
    
    Turn on ranger as the default vrp1 pass and adjust testcases.
    
            gcc/
            * params.opt (param_vrp1_mode): Make ranger default.
    
            gcc/testsuite/
            * gcc.dg/pr68217.c: Test [-INF, -INF][0, 0] instead of [-INF, 0].
            * gcc.dg/tree-ssa/vrp-unreachable.c: New.  Test unreachable removal.

diff --git a/gcc/params.opt b/gcc/params.opt
index 3001566e641..a34fee193fc 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1166,7 +1166,7 @@ Common Joined UInteger Var(param_vect_induction_float) Init(1) IntegerRage(0, 1)
 Enable loop vectorization of floating point inductions.
 
 -param=vrp1-mode=
-Common Joined Var(param_vrp1_mode) Enum(vrp_mode) Init(VRP_MODE_VRP) Param Optimization
+Common Joined Var(param_vrp1_mode) Enum(vrp_mode) Init(VRP_MODE_RANGER) Param Optimization
 --param=vrp1-mode=[vrp|ranger] Specifies the mode VRP1 should operate in.
 
 -param=vrp2-mode=
diff --git a/gcc/testsuite/gcc.dg/pr68217.c b/gcc/testsuite/gcc.dg/pr68217.c
index eb4f15e048f..60c80106760 100644
--- a/gcc/testsuite/gcc.dg/pr68217.c
+++ b/gcc/testsuite/gcc.dg/pr68217.c
@@ -10,4 +10,4 @@ int foo (void)
     return 0;
 }
 
-/* { dg-final { scan-tree-dump "\\\[-INF, 0\\\]" "vrp1" } } */
+/* { dg-final { scan-tree-dump "\\\[-INF, -INF\\\]\\\[0, 0\\\]" "vrp1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c
new file mode 100644
index 00000000000..cdc57403c6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-unreachable.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1-alias -fdump-tree-vrp2-alias" } */
+
+void dead (unsigned n);
+void alive (unsigned n);
+
+void func (unsigned n, unsigned m)
+{
+  if (n == 0)
+    __builtin_unreachable();
+  if (n == 1)
+    __builtin_unreachable();
+  if (n & 0x1)
+    __builtin_unreachable();
+  if (n == 2)
+    __builtin_unreachable();
+  if (n == 3)
+    __builtin_unreachable();
+  if (n & 0x2)
+    __builtin_unreachable();
+  if (n == 4)
+    __builtin_unreachable();
+  if (n == 5)
+    __builtin_unreachable();
+  if (n & 0x4)
+    __builtin_unreachable();
+  if (n == 6)
+    __builtin_unreachable();
+  if (n == 7)
+    __builtin_unreachable();
+ if (n <8)
+   dead (n);
+ if (n != m)
+    __builtin_unreachable();
+ alive (n);
+ alive (m);
+}
+
+/* { dg-final { scan-tree-dump-not "dead" "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "builtin_unreachable" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-not "builtin_unreachable" "vrp2" } } */
+/* { dg-final { scan-tree-dump-times "fff8" 4 "vrp2" } } */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-01 13:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-01 13:58 [COMMITTED] Make ranger the vrp1 default 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).