[committed] openmp: Simplify fold_build_pointer_plus callers in omp-expand

Message ID YuOULnBUr+5YLURu@tucnak
State Committed
Headers
Series [committed] openmp: Simplify fold_build_pointer_plus callers in omp-expand |

Commit Message

Jakub Jelinek July 29, 2022, 8:02 a.m. UTC
  Hi!

Tobias mentioned in PR106449 that fold_build_pointer_plus already
fold_converts the second argument to sizetype if it doesn't already
have an integral type gimple compatible with sizetype.

So, this patch simplifies the callers of fold_build_pointer_plus in
omp-expand so that they don't do those conversions manually.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2022-07-29  Jakub Jelinek  <jakub@redhat.com>

	* omp-expand.cc (expand_omp_for_init_counts, expand_omp_for_init_vars,
	extract_omp_for_update_vars, expand_omp_for_ordered_loops,
	expand_omp_simd): Don't fold_convert second argument to
	fold_build_pointer_plus to sizetype.



	Jakub
  

Patch

--- gcc/omp-expand.cc.jj	2022-06-28 13:03:30.930689700 +0200
+++ gcc/omp-expand.cc	2022-07-28 10:47:03.138939297 +0200
@@ -2267,8 +2267,7 @@  expand_omp_for_init_counts (struct omp_f
 	      else if (POINTER_TYPE_P (itype))
 		{
 		  gcc_assert (integer_onep (fd->loops[i].m1));
-		  t = fold_convert (sizetype,
-				    unshare_expr (fd->loops[i].n1));
+		  t = unshare_expr (fd->loops[i].n1);
 		  n1 = fold_build_pointer_plus (vs[i - fd->loops[i].outer], t);
 		}
 	      else
@@ -2291,8 +2290,7 @@  expand_omp_for_init_counts (struct omp_f
 	      else if (POINTER_TYPE_P (itype))
 		{
 		  gcc_assert (integer_onep (fd->loops[i].m2));
-		  t = fold_convert (sizetype,
-				    unshare_expr (fd->loops[i].n2));
+		  t = unshare_expr (fd->loops[i].n2);
 		  n2 = fold_build_pointer_plus (vs[i - fd->loops[i].outer], t);
 		}
 	      else
@@ -2353,8 +2351,7 @@  expand_omp_for_init_counts (struct omp_f
 	      tree step = fold_convert (itype,
 					unshare_expr (fd->loops[i].step));
 	      if (POINTER_TYPE_P (TREE_TYPE (vs[i])))
-		t = fold_build_pointer_plus (vs[i],
-					     fold_convert (sizetype, step));
+		t = fold_build_pointer_plus (vs[i], step);
 	      else
 		t = fold_build2 (PLUS_EXPR, itype, vs[i], step);
 	      t = force_gimple_operand_gsi (&gsi2, t, true, NULL_TREE,
@@ -2794,8 +2791,7 @@  expand_omp_for_init_vars (struct omp_for
 	      else if (POINTER_TYPE_P (itype))
 		{
 		  gcc_assert (integer_onep (fd->loops[j].m1));
-		  t = fold_convert (sizetype,
-				    unshare_expr (fd->loops[j].n1));
+		  t = unshare_expr (fd->loops[j].n1);
 		  n1 = fold_build_pointer_plus (vs[j - fd->loops[j].outer], t);
 		}
 	      else
@@ -2818,8 +2814,7 @@  expand_omp_for_init_vars (struct omp_for
 	      else if (POINTER_TYPE_P (itype))
 		{
 		  gcc_assert (integer_onep (fd->loops[j].m2));
-		  t = fold_convert (sizetype,
-				    unshare_expr (fd->loops[j].n2));
+		  t = unshare_expr (fd->loops[j].n2);
 		  n2 = fold_build_pointer_plus (vs[j - fd->loops[j].outer], t);
 		}
 	      else
@@ -2895,8 +2890,7 @@  expand_omp_for_init_vars (struct omp_for
 		  tree step
 		    = fold_convert (itype, unshare_expr (fd->loops[j].step));
 		  if (POINTER_TYPE_P (vtype))
-		    t = fold_build_pointer_plus (vs[j], fold_convert (sizetype,
-								      step));
+		    t = fold_build_pointer_plus (vs[j], step);
 		  else
 		    t = fold_build2 (PLUS_EXPR, itype, vs[j], step);
 		}
@@ -2959,8 +2953,7 @@  expand_omp_for_init_vars (struct omp_for
 		    = fold_convert (itype, unshare_expr (fd->loops[j].step));
 		  t = fold_build2 (MULT_EXPR, itype, t, t2);
 		  if (POINTER_TYPE_P (vtype))
-		    t = fold_build_pointer_plus (n1,
-						 fold_convert (sizetype, t));
+		    t = fold_build_pointer_plus (n1, t);
 		  else
 		    t = fold_build2 (PLUS_EXPR, itype, n1, t);
 		}
@@ -2970,8 +2963,7 @@  expand_omp_for_init_vars (struct omp_for
 		  t = fold_build2 (MULT_EXPR, itype, t,
 				   fold_convert (itype, fd->loops[j].step));
 		  if (POINTER_TYPE_P (vtype))
-		    t = fold_build_pointer_plus (fd->loops[j].n1,
-						 fold_convert (sizetype, t));
+		    t = fold_build_pointer_plus (fd->loops[j].n1, t);
 		  else
 		    t = fold_build2 (PLUS_EXPR, itype, fd->loops[j].n1, t);
 		}
@@ -3035,9 +3027,8 @@  expand_omp_for_init_vars (struct omp_for
 	  if (POINTER_TYPE_P (itype))
 	    {
 	      gcc_assert (integer_onep (fd->loops[i].m2));
-	      t = fold_convert (sizetype, unshare_expr (fd->loops[i].n2));
 	      t = fold_build_pointer_plus (fd->loops[i - fd->loops[i].outer].v,
-					   t);
+					   unshare_expr (fd->loops[i].n2));
 	    }
 	  else
 	    {
@@ -3130,7 +3121,7 @@  extract_omp_for_update_vars (struct omp_
 		{
 		  if (POINTER_TYPE_P (TREE_TYPE (l->v)))
 		    t = fold_build_pointer_plus (fd->loops[i + 1 - l->outer].v,
-						 fold_convert (sizetype, t));
+						 t);
 		  else
 		    {
 		      tree t2
@@ -3186,9 +3177,7 @@  extract_omp_for_update_vars (struct omp_
 		if (l->m1)
 		  {
 		    if (POINTER_TYPE_P (TREE_TYPE (l->v)))
-		      t = fold_build_pointer_plus (fd->loops[i].v,
-						   fold_convert (sizetype,
-								 l->n1));
+		      t = fold_build_pointer_plus (fd->loops[i].v, l->n1);
 		    else
 		      {
 			t = fold_build2 (MULT_EXPR, TREE_TYPE (l->m1), l->m1,
@@ -3210,9 +3199,7 @@  extract_omp_for_update_vars (struct omp_
 		if (l->m2)
 		  {
 		    if (POINTER_TYPE_P (TREE_TYPE (l->v)))
-		      t = fold_build_pointer_plus (fd->loops[i].v,
-						   fold_convert (sizetype,
-								 l->n2));
+		      t = fold_build_pointer_plus (fd->loops[i].v, l->n2);
 		    else
 		      {
 			t = fold_build2 (MULT_EXPR, TREE_TYPE (l->m2), l->m2,
@@ -3640,9 +3627,7 @@  expand_omp_for_ordered_loops (struct omp
 	{
 	  gsi = gsi_last_bb (cont_bb);
 	  if (POINTER_TYPE_P (type))
-	    t = fold_build_pointer_plus (fd->loops[i].v,
-					 fold_convert (sizetype,
-						       fd->loops[i].step));
+	    t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step);
 	  else
 	    t = fold_build2 (PLUS_EXPR, type, fd->loops[i].v,
 			     fold_convert (type, fd->loops[i].step));
@@ -6669,10 +6654,7 @@  expand_omp_simd (struct omp_region *regi
 	{
 	  i = fd->collapse - 1;
 	  if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i].v)))
-	    {
-	      t = fold_convert (sizetype, fd->loops[i].step);
-	      t = fold_build_pointer_plus (fd->loops[i].v, t);
-	    }
+	    t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step);
 	  else
 	    {
 	      t = fold_convert (TREE_TYPE (fd->loops[i].v),
@@ -6820,10 +6802,7 @@  expand_omp_simd (struct omp_region *regi
 	    e = EDGE_SUCC (last_bb, 1);
 	  basic_block bb = split_edge (e);
 	  if (POINTER_TYPE_P (TREE_TYPE (fd->loops[i].v)))
-	    {
-	      t = fold_convert (sizetype, fd->loops[i].step);
-	      t = fold_build_pointer_plus (fd->loops[i].v, t);
-	    }
+	    t = fold_build_pointer_plus (fd->loops[i].v, fd->loops[i].step);
 	  else
 	    {
 	      t = fold_convert (TREE_TYPE (fd->loops[i].v),