[GRAPHITE] Lift some IV restrictions

Message ID alpine.LSU.2.20.1710121627540.6597@zhemvz.fhfr.qr
State New
Headers show
Series
  • [GRAPHITE] Lift some IV restrictions
Related show

Commit Message

Richard Biener Oct. 12, 2017, 2:29 p.m.
The type check seems premature (we're checking CHRECs already) and
we certainly can handle POINTER IVs just fine.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

SPEC CPU 2k6 sees ~100 more loop nest optimizations that way.

Ok?

[I'd rather have problematical testcases for those weird
restrictions]

Thanks,
Richard.

2017-10-12  Richard Biener  <rguenther@suse.de>

	* graphite-scop-detection.c (loop_ivs_can_be_represented): Remove.
	(scop_detection::harmful_loop_in_region): Remove premature
	IV type restriction.
	(scop_detection::graphite_can_represent_scev): We can handle
	pointer IVs just fine.

Comments

Sebastian Pop Oct. 12, 2017, 2:43 p.m. | #1
On Oct 12, 2017 9:29 AM, "Richard Biener" <rguenther@suse.de> wrote:


The type check seems premature (we're checking CHRECs already) and
we certainly can handle POINTER IVs just fine.

Bootstrap / regtest running on x86_64-unknown-linux-gnu.

SPEC CPU 2k6 sees ~100 more loop nest optimizations that way.

Ok?

[I'd rather have problematical testcases for those weird
restrictions]


Sounds good.
Thanks.


Thanks,
Richard.

2017-10-12  Richard Biener  <rguenther@suse.de>

        * graphite-scop-detection.c (loop_ivs_can_be_represented): Remove.
        (scop_detection::harmful_loop_in_region): Remove premature
        IV type restriction.
        (scop_detection::graphite_can_represent_scev): We can handle
        pointer IVs just fine.

Index: gcc/graphite-scop-detection.c
===================================================================
--- gcc/graphite-scop-detection.c       (revision 253676)
+++ gcc/graphite-scop-detection.c       (working copy)
@@ -254,28 +254,6 @@ dot_cfg ()
   scops.release ();
 }

-/* Can all ivs be represented by a signed integer?
-   As isl might generate negative values in its expressions, signed loop
ivs
-   are required in the backend.  */
-
-static bool
-loop_ivs_can_be_represented (loop_p loop)
-{
-  unsigned type_long_long = TYPE_PRECISION (long_long_integer_type_node);
-  for (gphi_iterator psi = gsi_start_phis (loop->header); !gsi_end_p (psi);
-       gsi_next (&psi))
-    {
-      gphi *phi = psi.phi ();
-      tree res = PHI_RESULT (phi);
-      tree type = TREE_TYPE (res);
-
-      if (TYPE_UNSIGNED (type) && TYPE_PRECISION (type) >= type_long_long)
-       return false;
-    }
-
-  return true;
-}
-
 /* Returns a COND_EXPR statement when BB has a single predecessor, the
    edge between BB and its predecessor is not a loop exit edge, and
    the last statement of the single predecessor is a COND_EXPR.  */
@@ -822,13 +800,6 @@ scop_detection::harmful_loop_in_region (
          return true;
        }

-      if (! loop_ivs_can_be_represented (loop))
-       {
-         DEBUG_PRINT (dp << "[scop-detection-fail] loop_" << loop->num
-                      << "IV cannot be represented.\n");
-         return true;
-       }
-
       /* Check if all loop nests have at least one data reference.
         ???  This check is expensive and loops premature at this point.
         If important to retain we can pre-compute this for all innermost
@@ -968,14 +939,6 @@ scop_detection::graphite_can_represent_s
   if (chrec_contains_undetermined (scev))
     return false;

-  /* We disable the handling of pointer types, because it’s currently not
-     supported by Graphite with the isl AST generator. SSA_NAME nodes are
-     the only nodes, which are disabled in case they are pointers to object
-     types, but this can be changed.  */
-
-  if (POINTER_TYPE_P (TREE_TYPE (scev)) && TREE_CODE (scev) == SSA_NAME)
-    return false;
-
   switch (TREE_CODE (scev))
     {
     case NEGATE_EXPR:

Patch

Index: gcc/graphite-scop-detection.c
===================================================================
--- gcc/graphite-scop-detection.c	(revision 253676)
+++ gcc/graphite-scop-detection.c	(working copy)
@@ -254,28 +254,6 @@  dot_cfg ()
   scops.release ();
 }
 
-/* Can all ivs be represented by a signed integer?
-   As isl might generate negative values in its expressions, signed loop ivs
-   are required in the backend.  */
-
-static bool
-loop_ivs_can_be_represented (loop_p loop)
-{
-  unsigned type_long_long = TYPE_PRECISION (long_long_integer_type_node);
-  for (gphi_iterator psi = gsi_start_phis (loop->header); !gsi_end_p (psi);
-       gsi_next (&psi))
-    {
-      gphi *phi = psi.phi ();
-      tree res = PHI_RESULT (phi);
-      tree type = TREE_TYPE (res);
-
-      if (TYPE_UNSIGNED (type) && TYPE_PRECISION (type) >= type_long_long)
-	return false;
-    }
-
-  return true;
-}
-
 /* Returns a COND_EXPR statement when BB has a single predecessor, the
    edge between BB and its predecessor is not a loop exit edge, and
    the last statement of the single predecessor is a COND_EXPR.  */
@@ -822,13 +800,6 @@  scop_detection::harmful_loop_in_region (
 	  return true;
 	}
 
-      if (! loop_ivs_can_be_represented (loop))
-	{
-	  DEBUG_PRINT (dp << "[scop-detection-fail] loop_" << loop->num
-		       << "IV cannot be represented.\n");
-	  return true;
-	}
-
       /* Check if all loop nests have at least one data reference.
 	 ???  This check is expensive and loops premature at this point.
 	 If important to retain we can pre-compute this for all innermost
@@ -968,14 +939,6 @@  scop_detection::graphite_can_represent_s
   if (chrec_contains_undetermined (scev))
     return false;
 
-  /* We disable the handling of pointer types, because it’s currently not
-     supported by Graphite with the isl AST generator. SSA_NAME nodes are
-     the only nodes, which are disabled in case they are pointers to object
-     types, but this can be changed.  */
-
-  if (POINTER_TYPE_P (TREE_TYPE (scev)) && TREE_CODE (scev) == SSA_NAME)
-    return false;
-
   switch (TREE_CODE (scev))
     {
     case NEGATE_EXPR: