This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Some type verification fixes
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 14 Apr 2009 15:49:00 +0200 (CEST)
- Subject: [PATCH] Some type verification fixes
This fixes some type verification issues throughout the compiler
and prepares the verifier to deal with the vectorizer output more
generously.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2000-04-14 Richard Guenther <rguenther@suse.de>
* tree-cfg.c (verify_gimple_assign_unary): Adjust vector code
verification.
(verify_gimple_assign_binary): Likewise. Handle shifts and
rotates correctly.
(verify_gimple_phi): Print the mismatched argument position.
* tree-vect-loop-manip.c (vect_update_ivs_after_vectorizer):
Fix types.
(vect_update_init_of_dr): Likewise.
* matrix-reorg.c (transform_access_sites): Do what the
comment suggests.
* omp-low.c (expand_omp_atomic_pipeline): Use the correct types.
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c.orig 2009-04-14 10:17:06.000000000 +0200
--- gcc/tree-cfg.c 2009-04-14 11:51:15.000000000 +0200
*************** verify_gimple_assign_unary (gimple stmt)
*** 3411,3433 ****
return false;
}
! case TRUTH_NOT_EXPR:
! {
! }
case NEGATE_EXPR:
case ABS_EXPR:
case BIT_NOT_EXPR:
case PAREN_EXPR:
case NON_LVALUE_EXPR:
case CONJ_EXPR:
- case REDUC_MAX_EXPR:
- case REDUC_MIN_EXPR:
- case REDUC_PLUS_EXPR:
- case VEC_UNPACK_HI_EXPR:
- case VEC_UNPACK_LO_EXPR:
- case VEC_UNPACK_FLOAT_HI_EXPR:
- case VEC_UNPACK_FLOAT_LO_EXPR:
break;
default:
--- 3416,3438 ----
return false;
}
! case VEC_UNPACK_HI_EXPR:
! case VEC_UNPACK_LO_EXPR:
! case REDUC_MAX_EXPR:
! case REDUC_MIN_EXPR:
! case REDUC_PLUS_EXPR:
! case VEC_UNPACK_FLOAT_HI_EXPR:
! case VEC_UNPACK_FLOAT_LO_EXPR:
! /* FIXME. */
! return false;
+ case TRUTH_NOT_EXPR:
case NEGATE_EXPR:
case ABS_EXPR:
case BIT_NOT_EXPR:
case PAREN_EXPR:
case NON_LVALUE_EXPR:
case CONJ_EXPR:
break;
default:
*************** verify_gimple_assign_binary (gimple stmt
*** 3498,3514 ****
case LSHIFT_EXPR:
case RSHIFT_EXPR:
- if (FIXED_POINT_TYPE_P (rhs1_type)
- && INTEGRAL_TYPE_P (rhs2_type)
- && useless_type_conversion_p (lhs_type, rhs1_type))
- return false;
- /* Fall through. */
-
case LROTATE_EXPR:
case RROTATE_EXPR:
{
! if (!INTEGRAL_TYPE_P (rhs1_type)
! || !INTEGRAL_TYPE_P (rhs2_type)
|| !useless_type_conversion_p (lhs_type, rhs1_type))
{
error ("type mismatch in shift expression");
--- 3503,3523 ----
case LSHIFT_EXPR:
case RSHIFT_EXPR:
case LROTATE_EXPR:
case RROTATE_EXPR:
{
! /* Shifts and rotates are ok on integral types, fixed point
! types and integer vector types. */
! if ((!INTEGRAL_TYPE_P (rhs1_type)
! && !FIXED_POINT_TYPE_P (rhs1_type)
! && !(TREE_CODE (rhs1_type) == VECTOR_TYPE
! && TREE_CODE (TREE_TYPE (rhs1_type)) == INTEGER_TYPE))
! || (!INTEGRAL_TYPE_P (rhs2_type)
! /* Vector shifts of vectors are also ok. */
! && !(TREE_CODE (rhs1_type) == VECTOR_TYPE
! && TREE_CODE (TREE_TYPE (rhs1_type)) == INTEGER_TYPE
! && TREE_CODE (rhs2_type) == VECTOR_TYPE
! && TREE_CODE (TREE_TYPE (rhs2_type)) == INTEGER_TYPE))
|| !useless_type_conversion_p (lhs_type, rhs1_type))
{
error ("type mismatch in shift expression");
*************** verify_gimple_assign_binary (gimple stmt
*** 3614,3619 ****
--- 3623,3642 ----
break;
}
+ case WIDEN_SUM_EXPR:
+ case WIDEN_MULT_EXPR:
+ case VEC_WIDEN_MULT_HI_EXPR:
+ case VEC_WIDEN_MULT_LO_EXPR:
+ case VEC_PACK_TRUNC_EXPR:
+ case VEC_PACK_SAT_EXPR:
+ case VEC_PACK_FIX_TRUNC_EXPR:
+ case VEC_EXTRACT_EVEN_EXPR:
+ case VEC_EXTRACT_ODD_EXPR:
+ case VEC_INTERLEAVE_HIGH_EXPR:
+ case VEC_INTERLEAVE_LOW_EXPR:
+ /* FIXME. */
+ return false;
+
case MULT_EXPR:
case TRUNC_DIV_EXPR:
case CEIL_DIV_EXPR:
*************** verify_gimple_assign_binary (gimple stmt
*** 3630,3646 ****
case BIT_IOR_EXPR:
case BIT_XOR_EXPR:
case BIT_AND_EXPR:
- case WIDEN_SUM_EXPR:
- case WIDEN_MULT_EXPR:
- case VEC_WIDEN_MULT_HI_EXPR:
- case VEC_WIDEN_MULT_LO_EXPR:
- case VEC_PACK_TRUNC_EXPR:
- case VEC_PACK_SAT_EXPR:
- case VEC_PACK_FIX_TRUNC_EXPR:
- case VEC_EXTRACT_EVEN_EXPR:
- case VEC_EXTRACT_ODD_EXPR:
- case VEC_INTERLEAVE_HIGH_EXPR:
- case VEC_INTERLEAVE_LOW_EXPR:
/* Continue with generic binary expression handling. */
break;
--- 3653,3658 ----
*************** verify_gimple_phi (gimple stmt)
*** 3905,3911 ****
}
if (!useless_type_conversion_p (type, TREE_TYPE (arg)))
{
! error ("Incompatible types in PHI argument");
debug_generic_stmt (type);
debug_generic_stmt (TREE_TYPE (arg));
return true;
--- 3936,3942 ----
}
if (!useless_type_conversion_p (type, TREE_TYPE (arg)))
{
! error ("Incompatible types in PHI argument %u", i);
debug_generic_stmt (type);
debug_generic_stmt (TREE_TYPE (arg));
return true;
Index: gcc/tree-vect-loop-manip.c
===================================================================
*** gcc/tree-vect-loop-manip.c.orig 2009-04-14 10:17:06.000000000 +0200
--- gcc/tree-vect-loop-manip.c 2009-04-14 10:19:56.000000000 +0200
*************** vect_update_ivs_after_vectorizer (loop_v
*** 1639,1647 ****
if (POINTER_TYPE_P (TREE_TYPE (init_expr)))
ni = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (init_expr),
init_expr,
! fold_convert (sizetype,
! fold_build2 (MULT_EXPR, TREE_TYPE (niters),
! niters, step_expr)));
else
ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr),
fold_build2 (MULT_EXPR, TREE_TYPE (init_expr),
--- 1639,1647 ----
if (POINTER_TYPE_P (TREE_TYPE (init_expr)))
ni = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (init_expr),
init_expr,
! fold_build2 (MULT_EXPR, sizetype,
! fold_convert (sizetype, niters),
! step_expr));
else
ni = fold_build2 (PLUS_EXPR, TREE_TYPE (init_expr),
fold_build2 (MULT_EXPR, TREE_TYPE (init_expr),
*************** vect_update_init_of_dr (struct data_refe
*** 1926,1932 ****
niters = fold_build2 (MULT_EXPR, sizetype,
fold_convert (sizetype, niters),
fold_convert (sizetype, DR_STEP (dr)));
! offset = fold_build2 (PLUS_EXPR, sizetype, offset, niters);
DR_OFFSET (dr) = offset;
}
--- 1926,1933 ----
niters = fold_build2 (MULT_EXPR, sizetype,
fold_convert (sizetype, niters),
fold_convert (sizetype, DR_STEP (dr)));
! offset = fold_build2 (PLUS_EXPR, sizetype,
! fold_convert (sizetype, offset), niters);
DR_OFFSET (dr) = offset;
}
Index: gcc/matrix-reorg.c
===================================================================
*** gcc/matrix-reorg.c.orig 2009-04-04 11:28:46.000000000 +0200
--- gcc/matrix-reorg.c 2009-04-14 12:50:02.000000000 +0200
*************** transform_access_sites (void **slot, voi
*** 1865,1872 ****
tmp = create_tmp_var (TREE_TYPE (lhs), "new");
add_referenced_var (tmp);
rhs = gimple_assign_rhs1 (acc_info->stmt);
! new_stmt = gimple_build_assign (tmp,
! TREE_OPERAND (rhs, 0));
tmp = make_ssa_name (tmp, new_stmt);
gimple_assign_set_lhs (new_stmt, tmp);
gsi = gsi_for_stmt (acc_info->stmt);
--- 1865,1873 ----
tmp = create_tmp_var (TREE_TYPE (lhs), "new");
add_referenced_var (tmp);
rhs = gimple_assign_rhs1 (acc_info->stmt);
! rhs = fold_convert (TREE_TYPE (tmp),
! TREE_OPERAND (rhs, 0));
! new_stmt = gimple_build_assign (tmp, rhs);
tmp = make_ssa_name (tmp, new_stmt);
gimple_assign_set_lhs (new_stmt, tmp);
gsi = gsi_for_stmt (acc_info->stmt);
Index: gcc/omp-low.c
===================================================================
*** gcc/omp-low.c.orig 2009-04-09 09:59:43.000000000 +0200
--- gcc/omp-low.c 2009-04-14 13:09:54.000000000 +0200
*************** expand_omp_atomic_pipeline (basic_block
*** 5074,5080 ****
/* Build the compare&swap statement. */
new_storedi = build_call_expr (cmpxchg, 3, iaddr, loadedi, storedi);
new_storedi = force_gimple_operand_gsi (&si,
! fold_convert (itype, new_storedi),
true, NULL_TREE,
true, GSI_SAME_STMT);
--- 5074,5081 ----
/* Build the compare&swap statement. */
new_storedi = build_call_expr (cmpxchg, 3, iaddr, loadedi, storedi);
new_storedi = force_gimple_operand_gsi (&si,
! fold_convert (TREE_TYPE (loadedi),
! new_storedi),
true, NULL_TREE,
true, GSI_SAME_STMT);
*************** expand_omp_atomic_pipeline (basic_block
*** 5082,5088 ****
old_vali = loadedi;
else
{
! old_vali = create_tmp_var (itype, NULL);
if (gimple_in_ssa_p (cfun))
add_referenced_var (old_vali);
stmt = gimple_build_assign (old_vali, loadedi);
--- 5083,5089 ----
old_vali = loadedi;
else
{
! old_vali = create_tmp_var (TREE_TYPE (loadedi), NULL);
if (gimple_in_ssa_p (cfun))
add_referenced_var (old_vali);
stmt = gimple_build_assign (old_vali, loadedi);