re PR tree-optimization/31632 (ICE in compare_values)

PR tree-optimization/31632
	* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
	and arg1 for optimizations of comparison against min/max values.
	Fold arg0 to arg1's type for optimizations of comparison against
	min+1 and max-1 values.

	* gcc.c-torture/compile/20070419-1.c: New test.

From-SVN: r123988
This commit is contained in:
Jakub Jelinek 2007-04-20 13:40:47 +02:00
parent c1673e1b5a
commit 86122f7282
4 changed files with 61 additions and 25 deletions

View File

@ -1,3 +1,11 @@
2007-04-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/31632
* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
and arg1 for optimizations of comparison against min/max values.
Fold arg0 to arg1's type for optimizations of comparison against
min+1 and max-1 values.
2007-04-19 Bernd Schmidt <bernd.schmidt@analog.com>
* reload.c (combine_reloads): When trying to use a dying register,
@ -13,7 +21,6 @@
2007-04-19 Joseph Myers <joseph@codesourcery.com>
gcc/
* config/rs6000/spe.md (*frob_tf_ti, *frob_ti_tf, *frob_ti_tf_2,
*mov_si<mode>_e500_subreg0, *mov_si<mode>_e500_subreg0_2,
*mov_sitf_e500_subreg8, *mov_sitf_e500_subreg8_2, spe_extenddftf2,
@ -292,8 +299,8 @@
2007-04-16 Matthias Klose <doko@debian.org>
* gcc/config/alpha/linux.h (CPP_SPEC): Define.
* gcc/config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Extend.
* config/alpha/linux.h (CPP_SPEC): Define.
* config/arm/linux-gas.h (SUBTARGET_CPP_SPEC): Extend.
2007-04-16 Aldy Hernandez <aldyh@redhat.com>
@ -3505,7 +3512,7 @@
(thread_across_edge): Likewise.
* tree-flow.h (vrp_evaluate_conditional): Update declaration.
(thread_across_edge): Likewise.
* gcc/Makefile.in (tree-vrp.o): Depend upon intl.h.
* Makefile.in (tree-vrp.o): Depend upon intl.h.
2007-03-08 Uros Bizjak <ubizjak@gmail.com>
@ -6303,7 +6310,7 @@
2007-02-13 Stuart Hastings <stuart@apple.com>
* gcc/config/i386/i386.md (fixuns_truncdfhi2): Require SSE2.
* config/i386/i386.md (fixuns_truncdfhi2): Require SSE2.
2007-02-13 Richard Henderson <rth@redhat.com>
@ -6593,21 +6600,21 @@
2007-02-09 Stuart Hastings <stuart@apple.com>
Richard Henderson <rth@redhat.com>
* gcc/config/i386/i386.h (TARGET_KEEPS_VECTOR_ALIGNED_STACK): New.
* gcc/config/i386/darwin.h: (TARGET_KEEPS_VECTOR_ALIGNED_STACK): New.
* gcc/config/i386/i386.md (fixuns_trunc<mode>si2, fixuns_truncsfhi2,
* config/i386/i386.h (TARGET_KEEPS_VECTOR_ALIGNED_STACK): New.
* config/i386/darwin.h: (TARGET_KEEPS_VECTOR_ALIGNED_STACK): New.
* config/i386/i386.md (fixuns_trunc<mode>si2, fixuns_truncsfhi2,
fixuns_truncdfhi2): New.
(fix_truncsfdi_sse): Call ix86_expand_convert_sign_didf_sse.
(floatunsdidf2): Call ix86_expand_convert_uns_didf_sse.
(floatunssisf2): Add call to ix86_expand_convert_uns_sisf_sse.
(floatunssidf2): Allow nonimmediate source.
* gcc/config/i386/sse.md (movdi_to_sse): New.
* config/i386/sse.md (movdi_to_sse): New.
(vec_concatv2di): Drop '*'.
* gcc/config/i386/i386-protos.h (ix86_expand_convert_uns_si_sse,
* config/i386/i386-protos.h (ix86_expand_convert_uns_si_sse,
ix86_expand_convert_uns_didf_sse, ix86_expand_convert_uns_sidf_sse,
ix86_expand_convert_uns_sisf_sse, ix86_expand_convert_sign_didf_sse):
New.
* gcc/config/i386/i386.c (ix86_expand_convert_uns_si_sse,
* config/i386/i386.c (ix86_expand_convert_uns_si_sse,
ix86_expand_convert_uns_didf_sse, ix86_expand_convert_uns_sidf_sse,
ix86_expand_convert_uns_sisf_sse, ix86_expand_convert_sign_didf_sse,
ix86_build_const_vector, ix86_expand_vector_init_one_nonzero): New.
@ -7902,7 +7909,7 @@
2007-01-31 Kazu Hirata <kazu@codesourcery.com>
* gcc/config/arm/unwind-arm.h (_sleb128_t, _uleb128_t): New.
* config/arm/unwind-arm.h (_sleb128_t, _uleb128_t): New.
2007-01-30 Eric Christopher <echristo@apple.com>

View File

@ -11918,13 +11918,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return omit_one_operand (type, integer_zero_node, arg0);
case GE_EXPR:
return fold_build2 (EQ_EXPR, type, arg0, arg1);
return fold_build2 (EQ_EXPR, type, op0, op1);
case LE_EXPR:
return omit_one_operand (type, integer_one_node, arg0);
case LT_EXPR:
return fold_build2 (NE_EXPR, type, arg0, arg1);
return fold_build2 (NE_EXPR, type, op0, op1);
/* The GE_EXPR and LT_EXPR cases above are not normally
reached because of previous transformations. */
@ -11940,11 +11940,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
case GT_EXPR:
arg1 = const_binop (PLUS_EXPR, arg1,
build_int_cst (TREE_TYPE (arg1), 1), 0);
return fold_build2 (EQ_EXPR, type, arg0, arg1);
return fold_build2 (EQ_EXPR, type,
fold_convert (TREE_TYPE (arg1), arg0),
arg1);
case LE_EXPR:
arg1 = const_binop (PLUS_EXPR, arg1,
build_int_cst (TREE_TYPE (arg1), 1), 0);
return fold_build2 (NE_EXPR, type, arg0, arg1);
return fold_build2 (NE_EXPR, type,
fold_convert (TREE_TYPE (arg1), arg0),
arg1);
default:
break;
}
@ -11957,7 +11961,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return omit_one_operand (type, integer_zero_node, arg0);
case LE_EXPR:
return fold_build2 (EQ_EXPR, type, arg0, arg1);
return fold_build2 (EQ_EXPR, type, op0, op1);
case GE_EXPR:
return omit_one_operand (type, integer_one_node, arg0);
@ -11975,10 +11979,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
{
case GE_EXPR:
arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0);
return fold_build2 (NE_EXPR, type, arg0, arg1);
return fold_build2 (NE_EXPR, type,
fold_convert (TREE_TYPE (arg1), arg0),
arg1);
case LT_EXPR:
arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0);
return fold_build2 (EQ_EXPR, type, arg0, arg1);
return fold_build2 (EQ_EXPR, type,
fold_convert (TREE_TYPE (arg1), arg0),
arg1);
default:
break;
}
@ -11998,12 +12006,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
and X >= signed_max+1 because previous transformations. */
if (code == LE_EXPR || code == GT_EXPR)
{
tree st0, st1;
st0 = lang_hooks.types.signed_type (TREE_TYPE (arg0));
st1 = lang_hooks.types.signed_type (TREE_TYPE (arg1));
return fold_build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR,
type, fold_convert (st0, arg0),
build_int_cst (st1, 0));
tree st;
st = lang_hooks.types.signed_type (TREE_TYPE (arg1));
return fold_build2 (code == LE_EXPR ? GE_EXPR : LT_EXPR,
type, fold_convert (st, arg0),
build_int_cst (st, 0));
}
}
}

View File

@ -1,3 +1,8 @@
2007-04-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/31632
* gcc.c-torture/compile/20070419-1.c: New test.
2007-04-19 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/invalid-call-1.c: New test.

View File

@ -0,0 +1,17 @@
/* PR tree-optimization/31632 */
struct S
{
long int l;
void *m;
};
int
foo (struct S *x)
{
unsigned long a;
a = x->l;
if (a <= ((void *) 0))
x->m = 0;
return 0;
}