This backport contains 2 patch from gcc main stream tree. The commit id of these patchs list as following in the order of time. 0001-Fix-type-mismatch-in-SLPed-constructors.patch 86c3a7d891f9f175d09d61f5ce163c6dc5ce681f 0001-re-PR-fortran-91003-ICE-when-compiling-LAPACK-CGEGV-.patch d005f61e7a0dbb2c991f13b4b61b1a27ca2d8b73 diff -urpN a/gcc/testsuite/gfortran.dg/pr91003.f90 b/gcc/testsuite/gfortran.dg/pr91003.f90 --- a/gcc/testsuite/gfortran.dg/pr91003.f90 1969-12-31 19:00:00.000000000 -0500 +++ b/gcc/testsuite/gfortran.dg/pr91003.f90 2021-02-22 03:02:39.484000000 -0500 @@ -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 -urpN a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c --- a/gcc/tree-vect-slp.c 2021-02-22 02:56:51.328000000 -0500 +++ b/gcc/tree-vect-slp.c 2021-02-22 03:03:22.676000000 -0500 @@ -3442,7 +3442,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; @@ -3467,9 +3467,17 @@ vect_mask_constant_operand_p (stmt_vec_i 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 (); @@ -3600,9 +3608,10 @@ duplicate_and_interleave (vec_info *vinf 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 *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; @@ -3624,7 +3633,7 @@ vect_get_constant_vectors (slp_tree op_n /* 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); @@ -3848,7 +3857,7 @@ vect_get_slp_defs (slp_tree slp_node, ve 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); } @@ -4269,6 +4278,10 @@ vectorize_slp_instance_root_stmt (slp_tr { tree vect_lhs = gimple_get_lhs (child_stmt_info->stmt); tree root_lhs = gimple_get_lhs (instance->root_stmt->stmt); + if (!useless_type_conversion_p (TREE_TYPE (root_lhs), + TREE_TYPE (vect_lhs))) + vect_lhs = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (root_lhs), + vect_lhs); rstmt = gimple_build_assign (root_lhs, vect_lhs); break; }