Lines 7739-7745
vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
Link Here
|
7739 |
enum vect_def_type dts[2] = {vect_unknown_def_type, vect_unknown_def_type}; |
7739 |
enum vect_def_type dts[2] = {vect_unknown_def_type, vect_unknown_def_type}; |
7740 |
unsigned nunits; |
7740 |
unsigned nunits; |
7741 |
int ncopies; |
7741 |
int ncopies; |
7742 |
enum tree_code code; |
7742 |
enum tree_code code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; |
7743 |
stmt_vec_info prev_stmt_info = NULL; |
7743 |
stmt_vec_info prev_stmt_info = NULL; |
7744 |
int i, j; |
7744 |
int i, j; |
7745 |
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info); |
7745 |
bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info); |
Lines 7812-7822
vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
Link Here
|
7812 |
else if (nunits != TYPE_VECTOR_SUBPARTS (vectype)) |
7812 |
else if (nunits != TYPE_VECTOR_SUBPARTS (vectype)) |
7813 |
return false; |
7813 |
return false; |
7814 |
|
7814 |
|
|
|
7815 |
/* Can't compare mask and non-mask types. */ |
7816 |
if (vectype1 && vectype2 |
7817 |
&& (VECTOR_BOOLEAN_TYPE_P (vectype1) ^ VECTOR_BOOLEAN_TYPE_P (vectype2))) |
7818 |
return false; |
7819 |
|
7820 |
/* Boolean values may have another representation in vectors |
7821 |
and therefore we prefer bit operations over comparison for |
7822 |
them (which also works for scalar masks). We store opcodes |
7823 |
to use in bitop1 and bitop2. Statement is vectorized as |
7824 |
BITOP2 (rhs1 BITOP1 rhs2) or |
7825 |
rhs1 BITOP2 (BITOP1 rhs2) |
7826 |
depending on bitop1 and bitop2 arity. */ |
7827 |
if (VECTOR_BOOLEAN_TYPE_P (vectype)) |
7828 |
{ |
7829 |
if (code == GT_EXPR) |
7830 |
{ |
7831 |
bitop1 = BIT_NOT_EXPR; |
7832 |
bitop2 = BIT_AND_EXPR; |
7833 |
} |
7834 |
else if (code == GE_EXPR) |
7835 |
{ |
7836 |
bitop1 = BIT_NOT_EXPR; |
7837 |
bitop2 = BIT_IOR_EXPR; |
7838 |
} |
7839 |
else if (code == LT_EXPR) |
7840 |
{ |
7841 |
bitop1 = BIT_NOT_EXPR; |
7842 |
bitop2 = BIT_AND_EXPR; |
7843 |
std::swap (rhs1, rhs2); |
7844 |
} |
7845 |
else if (code == LE_EXPR) |
7846 |
{ |
7847 |
bitop1 = BIT_NOT_EXPR; |
7848 |
bitop2 = BIT_IOR_EXPR; |
7849 |
std::swap (rhs1, rhs2); |
7850 |
} |
7851 |
else |
7852 |
{ |
7853 |
bitop1 = BIT_XOR_EXPR; |
7854 |
if (code == EQ_EXPR) |
7855 |
bitop2 = BIT_NOT_EXPR; |
7856 |
} |
7857 |
} |
7858 |
|
7815 |
if (!vec_stmt) |
7859 |
if (!vec_stmt) |
7816 |
{ |
7860 |
{ |
7817 |
STMT_VINFO_TYPE (stmt_info) = comparison_vec_info_type; |
7861 |
STMT_VINFO_TYPE (stmt_info) = comparison_vec_info_type; |
7818 |
vect_model_simple_cost (stmt_info, ncopies, dts, NULL, NULL); |
7862 |
if (bitop1 == NOP_EXPR) |
7819 |
return expand_vec_cmp_expr_p (vectype, mask_type); |
7863 |
{ |
|
|
7864 |
vect_model_simple_cost (stmt_info, ncopies, dts, NULL, NULL); |
7865 |
return expand_vec_cmp_expr_p (vectype, mask_type); |
7866 |
} |
7867 |
else |
7868 |
{ |
7869 |
machine_mode mode = TYPE_MODE (vectype); |
7870 |
optab optab; |
7871 |
|
7872 |
vect_model_simple_cost (stmt_info, ncopies, dts, NULL, NULL); |
7873 |
optab = optab_for_tree_code (bitop1, vectype, optab_default); |
7874 |
if (!optab || optab_handler (optab, mode) == CODE_FOR_nothing) |
7875 |
return false; |
7876 |
|
7877 |
if (bitop2 != NOP_EXPR) |
7878 |
{ |
7879 |
optab = optab_for_tree_code (bitop2, vectype, optab_default); |
7880 |
if (!optab || optab_handler (optab, mode) == CODE_FOR_nothing) |
7881 |
return false; |
7882 |
} |
7883 |
return true; |
7884 |
} |
7820 |
} |
7885 |
} |
7821 |
|
7886 |
|
7822 |
/* Transform. */ |
7887 |
/* Transform. */ |
Lines 7873-7880
vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi,
Link Here
|
7873 |
vec_rhs2 = vec_oprnds1[i]; |
7938 |
vec_rhs2 = vec_oprnds1[i]; |
7874 |
|
7939 |
|
7875 |
new_temp = make_ssa_name (mask); |
7940 |
new_temp = make_ssa_name (mask); |
7876 |
new_stmt = gimple_build_assign (new_temp, code, vec_rhs1, vec_rhs2); |
7941 |
if (bitop1 == NOP_EXPR) |
7877 |
vect_finish_stmt_generation (stmt, new_stmt, gsi); |
7942 |
{ |
|
|
7943 |
new_stmt = gimple_build_assign (new_temp, code, |
7944 |
vec_rhs1, vec_rhs2); |
7945 |
vect_finish_stmt_generation (stmt, new_stmt, gsi); |
7946 |
} |
7947 |
else |
7948 |
{ |
7949 |
if (bitop1 == BIT_NOT_EXPR) |
7950 |
new_stmt = gimple_build_assign (new_temp, bitop1, vec_rhs2); |
7951 |
else |
7952 |
new_stmt = gimple_build_assign (new_temp, bitop1, vec_rhs1, |
7953 |
vec_rhs2); |
7954 |
vect_finish_stmt_generation (stmt, new_stmt, gsi); |
7955 |
if (bitop2 != NOP_EXPR) |
7956 |
{ |
7957 |
tree res = make_ssa_name (mask); |
7958 |
if (bitop2 == BIT_NOT_EXPR) |
7959 |
new_stmt = gimple_build_assign (res, bitop2, new_temp); |
7960 |
else |
7961 |
new_stmt = gimple_build_assign (res, bitop2, vec_rhs1, |
7962 |
new_temp); |
7963 |
vect_finish_stmt_generation (stmt, new_stmt, gsi); |
7964 |
} |
7965 |
} |
7878 |
if (slp_node) |
7966 |
if (slp_node) |
7879 |
SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt); |
7967 |
SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt); |
7880 |
} |
7968 |
} |