diff mbox series

[COMMITTED] For ranges, PHIs don't need to process arg == def.

Message ID 87d2111a-a8fd-b2bb-52e7-3c91e760b552@redhat.com
State New
Headers show
Series [COMMITTED] For ranges, PHIs don't need to process arg == def. | expand

Commit Message

Andrew MacLeod Nov. 3, 2021, 2:39 p.m. UTC
If an argument of a phi is the same as the DEF of the phi, then the 
range on the incoming edge doesn't need to be taken into account since 
it can't be anything other than itself.  All this can do is pessimize 
the calculated result.

ie, for something like

a_2 = phi<0(2), a_2(6)>

a_2 can never be anything other than [0,0], no matter what value comes 
in on edge 6, so lets not even check.

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

Andrew
diff mbox series

Patch

From 6d936684fcf9bbb55837e3a87ae2221d5ec9b5b7 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Tue, 2 Nov 2021 09:46:53 -0400
Subject: [PATCH 4/6] For ranges, PHIs don't need to process arg == def.

If an argument of a phi is the same as the DEF of the phi, then the range
on the incoming edge doesn't need to be taken into account since it can't
be anything other than itself.

	* gimple-range-fold.cc (fold_using_range::range_of_phi): Don't import
	a range from edge if arg == phidef.
---
 gcc/gimple-range-fold.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 6cc7753a750..608d98b43d5 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -779,6 +779,10 @@  fold_using_range::range_of_phi (irange &r, gphi *phi, fur_source &src)
   for (x = 0; x < gimple_phi_num_args (phi); x++)
     {
       tree arg = gimple_phi_arg_def (phi, x);
+      // An argument that is the same as the def provides no new range.
+      if (arg == phi_def)
+	continue;
+
       edge e = gimple_phi_arg_edge (phi, x);
 
       // Get the range of the argument on its edge.
-- 
2.17.2