diff mbox series

[COMMITTED] Make ranger the vrp1 default.

Message ID 100da11f-424c-71e0-1275-f161b94ffa46@redhat.com
State New
Headers show
Series [COMMITTED] Make ranger the vrp1 default. | expand

Commit Message

Andrew MacLeod Nov. 1, 2022, 1:58 p.m. UTC
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
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 mbox series

Patch

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" } } */