aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-29 19:54:25 +0000
committerRichard Biener <rguenther@suse.de>2019-11-29 19:54:25 +0000
commit98a4f8094bba71217d1a7b77b8cdd55298c002f6 (patch)
treeb81bd53d5b8ffaad0acdf0605109ada9cc2737df
parentf138cee2ff25318432679a6d289659363099a462 (diff)
2019-11-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/91003 * tree-vect-slp.c (vect_mask_constant_operand_p): Pass in the operand number, avoid handling the non-condition operands of COND_EXPRs as comparisons. (vect_get_constant_vectors): Pass down the operand number. (vect_get_slp_defs): Likewise. * gfortran.dg/pr91003.f90: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278860 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gfortran.dg/pr91003.f9033
-rw-r--r--gcc/tree-vect-slp.c21
4 files changed, 62 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2b2cde341fa..98a93a5086e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2019-11-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/91003
+ * tree-vect-slp.c (vect_mask_constant_operand_p): Pass in the
+ operand number, avoid handling the non-condition operands of
+ COND_EXPRs as comparisons.
+ (vect_get_constant_vectors): Pass down the operand number.
+ (vect_get_slp_defs): Likewise.
+
2019-11-29 Frederik Harwath <frederik@codesourcery.com>
* gimple-match-head.c (maybe_resimplify_conditional_op): Use
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 375202bc493..ad1be1daaed 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/91003
+ * gfortran.dg/pr91003.f90: New testcase.
+
2019-11-29 Richard Sandiford <richard.sandiford@arm.com>
PR tree-optimization/92677
diff --git a/gcc/testsuite/gfortran.dg/pr91003.f90 b/gcc/testsuite/gfortran.dg/pr91003.f90
new file mode 100644
index 00000000000..ed5063d6365
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr91003.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-Ofast" }
+ SUBROUTINE FOO(N, A, B, C, D, E, F, G)
+ COMPLEX A(*)
+ LOGICAL H
+ INTEGER G
+ REAL I, C, J, F, F1, F2, K, E, L, M, B, D
+ DO JC = 1, N
+ K = F*REAL(A(JC))
+ Z = F*AIMAG(A(JC))
+ H = .FALSE.
+ L = G
+ IF(ABS(Z).LT.D .AND. I.GE. MAX(D, B*C, B*J)) THEN
+ H = .TRUE.
+ L = (D / F1) / MAX(D, F2*I)
+ END IF
+ IF(ABS(K).LT.D .AND. C.GE. MAX(D, B*I, B*J)) THEN
+ L = MAX(L, (D / F1) / MAX(D, F2*C))
+ END IF
+ IF(ABS(E).LT.D .AND. J.GE. MAX(D, B*C, B*I)) THEN
+ H = .TRUE.
+ L = MAX(L, (D / BNRM1) / MAX(D, BNRM2*J))
+ END IF
+ IF(H) THEN
+ M = (L*D)*MAX(ABS(K), ABS(Z), ABS(E))
+ END IF
+ IF(H) THEN
+ K = (L*REAL(A(JC)))*F
+ Z = (L*AIMAG(A(JC)))*F
+ END IF
+ A(JC) = CMPLX(K, Z)
+ END DO
+ END
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 0d420e44bb0..e35cb7328bd 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3447,7 +3447,7 @@ vect_slp_bb (basic_block bb)
/* Return 1 if vector type STMT_VINFO is a boolean vector. */
static bool
-vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo)
+vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo, unsigned op_num)
{
enum tree_code code = gimple_expr_code (stmt_vinfo->stmt);
tree op, vectype;
@@ -3472,9 +3472,17 @@ vect_mask_constant_operand_p (stmt_vec_info stmt_vinfo)
tree cond = gimple_assign_rhs1 (stmt);
if (TREE_CODE (cond) == SSA_NAME)
- op = cond;
+ {
+ if (op_num > 0)
+ return VECTOR_BOOLEAN_TYPE_P (STMT_VINFO_VECTYPE (stmt_vinfo));
+ op = cond;
+ }
else
- op = TREE_OPERAND (cond, 0);
+ {
+ if (op_num > 1)
+ return VECTOR_BOOLEAN_TYPE_P (STMT_VINFO_VECTYPE (stmt_vinfo));
+ op = TREE_OPERAND (cond, 0);
+ }
if (!vect_is_simple_use (op, stmt_vinfo->vinfo, &dt, &vectype))
gcc_unreachable ();
@@ -3605,9 +3613,10 @@ duplicate_and_interleave (vec_info *vinfo, gimple_seq *seq, tree vector_type,
operands. */
static void
-vect_get_constant_vectors (slp_tree op_node, slp_tree slp_node,
+vect_get_constant_vectors (slp_tree slp_node, unsigned op_num,
vec<tree> *vec_oprnds)
{
+ slp_tree op_node = SLP_TREE_CHILDREN (slp_node)[op_num];
stmt_vec_info stmt_vinfo = SLP_TREE_SCALAR_STMTS (slp_node)[0];
vec_info *vinfo = stmt_vinfo->vinfo;
unsigned HOST_WIDE_INT nunits;
@@ -3629,7 +3638,7 @@ vect_get_constant_vectors (slp_tree op_node, slp_tree slp_node,
/* Check if vector type is a boolean vector. */
tree stmt_vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
if (VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (op))
- && vect_mask_constant_operand_p (stmt_vinfo))
+ && vect_mask_constant_operand_p (stmt_vinfo, op_num))
vector_type = truth_type_for (stmt_vectype);
else
vector_type = get_vectype_for_scalar_type (vinfo, TREE_TYPE (op), op_node);
@@ -3862,7 +3871,7 @@ vect_get_slp_defs (slp_tree slp_node, vec<vec<tree> > *vec_oprnds, unsigned n)
vect_get_slp_vect_defs (child, &vec_defs);
}
else
- vect_get_constant_vectors (child, slp_node, &vec_defs);
+ vect_get_constant_vectors (slp_node, i, &vec_defs);
vec_oprnds->quick_push (vec_defs);
}