diff options
author | Artjoms Sinkarovs <artyom.shinkaroff@gmail.com> | 2011-08-29 11:55:45 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2011-08-29 11:55:45 +0000 |
commit | 544d960a12742dbe8c8e9a968764d4502b239a26 (patch) | |
tree | a6235b0de2204188ae68275b478b1d3c90038b41 /gcc/tree-cfg.c | |
parent | 776bebcdb0de9557b40aa5496c016588da845398 (diff) | |
download | gcc-544d960a12742dbe8c8e9a968764d4502b239a26.zip gcc-544d960a12742dbe8c8e9a968764d4502b239a26.tar.gz gcc-544d960a12742dbe8c8e9a968764d4502b239a26.tar.bz2 |
20011-08-29 Artjoms Sinkarovs <artyom.shinkaroff@gmail.com>
Richard Guenther <rguenther@suse.de>
* tree.h (constant_boolean_node): Adjust prototype.
* fold-const.c (fold_convert_loc): Move aggregate conversion
leeway down.
(constant_boolean_node): Make value parameter boolean, add
vector type handling.
(fold_unary_loc): Use constant_boolean_node.
(fold_binary_loc): Preserve types properly when folding
COMPLEX_EXPR <__real x, __imag x>.
* gimplify.c (gimplify_expr): Handle vector comparison.
* tree.def (EQ_EXPR, ...): Document behavior on vector typed
comparison.
* tree-cfg.c (verify_gimple_comparison): Verify vector typed
comparisons.
From-SVN: r178209
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 54 |
1 files changed, 42 insertions, 12 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index b266d1b..bcb8ba9 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3193,25 +3193,55 @@ verify_gimple_comparison (tree type, tree op0, tree op1) effective type the comparison is carried out in. Instead we require that either the first operand is trivially convertible into the second, or the other way around. - The resulting type of a comparison may be any integral type. Because we special-case pointers to void we allow comparisons of pointers with the same mode as well. */ - if ((!useless_type_conversion_p (op0_type, op1_type) - && !useless_type_conversion_p (op1_type, op0_type) - && (!POINTER_TYPE_P (op0_type) - || !POINTER_TYPE_P (op1_type) - || TYPE_MODE (op0_type) != TYPE_MODE (op1_type))) - || !INTEGRAL_TYPE_P (type) - || (TREE_CODE (type) != BOOLEAN_TYPE - && TYPE_PRECISION (type) != 1)) - { - error ("type mismatch in comparison expression"); - debug_generic_expr (type); + if (!useless_type_conversion_p (op0_type, op1_type) + && !useless_type_conversion_p (op1_type, op0_type) + && (!POINTER_TYPE_P (op0_type) + || !POINTER_TYPE_P (op1_type) + || TYPE_MODE (op0_type) != TYPE_MODE (op1_type))) + { + error ("mismatching comparison operand types"); debug_generic_expr (op0_type); debug_generic_expr (op1_type); return true; } + /* The resulting type of a comparison may be an effective boolean type. */ + if (INTEGRAL_TYPE_P (type) + && (TREE_CODE (type) == BOOLEAN_TYPE + || TYPE_PRECISION (type) == 1)) + ; + /* Or an integer vector type with the same size and element count + as the comparison operand types. */ + else if (TREE_CODE (type) == VECTOR_TYPE + && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE) + { + if (TREE_CODE (op0_type) != VECTOR_TYPE + || TREE_CODE (op1_type) != VECTOR_TYPE) + { + error ("non-vector operands in vector comparison"); + debug_generic_expr (op0_type); + debug_generic_expr (op1_type); + return true; + } + + if (TYPE_VECTOR_SUBPARTS (type) != TYPE_VECTOR_SUBPARTS (op0_type) + || (GET_MODE_SIZE (TYPE_MODE (type)) + != GET_MODE_SIZE (TYPE_MODE (op0_type)))) + { + error ("invalid vector comparison resulting type"); + debug_generic_expr (type); + return true; + } + } + else + { + error ("bogus comparison result type"); + debug_generic_expr (type); + return true; + } + return false; } |