This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix MIN_EXPR/MAX_EXPR expansion for vector types (PR rtl-optimization/79901)


Hi!

This is the middle-end for the same PR.  While supporting min/max for
avx512f V8DI generates of course better code, when the backend claims it is
not available, we should not ICE on that by trying to expand the vector
min/max by expanding comparison and jump.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-03-06  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/79901
	* expr.c (expand_expr_real_2): For vector MIN/MAX, if there is no
	min/max expander, expand it using expand_vec_cond_expr.

--- gcc/expr.c.jj	2017-03-02 10:15:32.000000000 +0100
+++ gcc/expr.c	2017-03-06 16:07:56.159868534 +0100
@@ -8943,6 +8943,18 @@ expand_expr_real_2 (sepops ops, rtx targ
       if (temp != 0)
 	return temp;
 
+      /* For vector MIN <x, y>, expand it a VEC_COND_EXPR <x <= y, x, y>
+	 and similarly for MAX <x, y>.  */
+      if (VECTOR_TYPE_P (type))
+	{
+	  tree t0 = make_tree (type, op0);
+	  tree t1 = make_tree (type, op1);
+	  tree comparison = build2 (code == MIN_EXPR ? LE_EXPR : GE_EXPR,
+				    type, t0, t1);
+	  return expand_vec_cond_expr (type, comparison, t0, t1,
+				       original_target);
+	}
+
       /* At this point, a MEM target is no longer useful; we will get better
 	 code without it.  */
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]