diff options
author | liuhongt <hongtao.liu@intel.com> | 2021-09-02 13:05:54 +0800 |
---|---|---|
committer | liuhongt <hongtao.liu@intel.com> | 2021-09-16 16:35:29 +0800 |
commit | a26ff83ed07e33c4aa46f3314553c0d15ca21100 (patch) | |
tree | 5f6c5fa4a159fb95184b17896df2a1ada6e72059 /gcc/tree.c | |
parent | a73d59089a9daca7316eeccece13166ad60dbf13 (diff) | |
download | gcc-a26ff83ed07e33c4aa46f3314553c0d15ca21100.zip gcc-a26ff83ed07e33c4aa46f3314553c0d15ca21100.tar.gz gcc-a26ff83ed07e33c4aa46f3314553c0d15ca21100.tar.bz2 |
Check mask type when doing cond_op related gimple simplification.
gcc/ChangeLog:
PR middle-end/102080
* match.pd: Check mask type when doing cond_op related gimple
simplification.
* tree.c (is_truth_type_for): New function.
* tree.h (is_truth_type_for): New declaration.
gcc/testsuite/ChangeLog:
PR middle-end/102080
* gcc.target/i386/pr102080.c: New test.
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -10737,6 +10737,35 @@ signed_type_for (tree type) return signed_or_unsigned_type_for (0, type); } +/* - For VECTOR_TYPEs: + - The truth type must be a VECTOR_BOOLEAN_TYPE. + - The number of elements must match (known_eq). + - targetm.vectorize.get_mask_mode exists, and exactly + the same mode as the truth type. + - Otherwise, the truth type must be a BOOLEAN_TYPE + or useless_type_conversion_p to BOOLEAN_TYPE. */ +bool +is_truth_type_for (tree type, tree truth_type) +{ + machine_mode mask_mode = TYPE_MODE (truth_type); + machine_mode vmode = TYPE_MODE (type); + machine_mode tmask_mode; + + if (TREE_CODE (type) == VECTOR_TYPE) + { + if (VECTOR_BOOLEAN_TYPE_P (truth_type) + && known_eq (TYPE_VECTOR_SUBPARTS (type), + TYPE_VECTOR_SUBPARTS (truth_type)) + && targetm.vectorize.get_mask_mode (vmode).exists (&tmask_mode) + && tmask_mode == mask_mode) + return true; + + return false; + } + + return useless_type_conversion_p (boolean_type_node, truth_type); +} + /* If TYPE is a vector type, return a signed integer vector type with the same width and number of subparts. Otherwise return boolean_type_node. */ |