diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 396579e94a5..cc638b30e0e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2007-04-20 Jakub Jelinek + + 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 * reload.c (combine_reloads): When trying to use a dying register, @@ -13,7 +21,6 @@ 2007-04-19 Joseph Myers - gcc/ * config/rs6000/spe.md (*frob_tf_ti, *frob_ti_tf, *frob_ti_tf_2, *mov_si_e500_subreg0, *mov_si_e500_subreg0_2, *mov_sitf_e500_subreg8, *mov_sitf_e500_subreg8_2, spe_extenddftf2, @@ -292,8 +299,8 @@ 2007-04-16 Matthias Klose - * 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 @@ -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 @@ -6303,7 +6310,7 @@ 2007-02-13 Stuart Hastings - * gcc/config/i386/i386.md (fixuns_truncdfhi2): Require SSE2. + * config/i386/i386.md (fixuns_truncdfhi2): Require SSE2. 2007-02-13 Richard Henderson @@ -6593,21 +6600,21 @@ 2007-02-09 Stuart Hastings Richard Henderson - * 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_truncsi2, 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_truncsi2, 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 - * 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 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3f03cc97818..6d2db7b876e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)); } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 501825d28a6..2cb05104d78 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-04-20 Jakub Jelinek + + PR tree-optimization/31632 + * gcc.c-torture/compile/20070419-1.c: New test. + 2007-04-19 Eric Botcazou * gcc.dg/invalid-call-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/20070419-1.c b/gcc/testsuite/gcc.c-torture/compile/20070419-1.c new file mode 100644 index 00000000000..ea23bf8bdc0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20070419-1.c @@ -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; +}