On 24/06/14 22:21, Jakub Jelinek wrote: > On Tue, Jun 24, 2014 at 09:53:35PM +1000, Kugan wrote: >> 2014-06-24 Kugan Vivekanandarajah >> >> * gcc/calls.c (precompute_arguments: Check is_promoted_for_type >> and set the promoted mode. >> (is_promoted_for_type) : New function. >> (expand_expr_real_1) : Check is_promoted_for_type >> and set the promoted mode. >> * gcc/expr.h (is_promoted_for_type) : New function definition. >> * gcc/cfgexpand.c (expand_gimple_stmt_1) : Call emit_move_insn if >> SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED. > > Similarly to the other patch, no gcc/ prefix in ChangeLog, no space before > :, watch for too long lines, remove useless ()s around conditions. Changed it. >> +bool >> +is_promoted_for_type (tree ssa, enum machine_mode lhs_mode, bool lhs_uns) >> +{ >> + wide_int type_min, type_max; >> + wide_int min, max, limit; >> + unsigned int prec; >> + tree lhs_type; >> + bool rhs_uns; >> + >> + if (flag_wrapv > > Why? > >> + || (flag_strict_overflow == false) > > Why? Also, that would be !flag_strict_overflow instead of > (flag_strict_overflow == false) For these flags, value ranges generated are not usable for extension eliminations. Therefore, without this some of the test cases in regression fails. For example: short a; void foo (void) { for (a = 0; a >= 0; a++) ; } -Os -fno-strict-overflow produces the following range for the index increment and hence goes into infinite loop. _10: [1, 32768] _10 = _4 + 1; > >> + || (ssa == NULL_TREE) >> + || (TREE_CODE (ssa) != SSA_NAME) >> + || !INTEGRAL_TYPE_P (TREE_TYPE (ssa)) >> + || POINTER_TYPE_P (TREE_TYPE (ssa))) > > All pointer types are !INTEGRAL_TYPE_P, so the last condition > doesn't make any sense. I have changed this. Please see the attached patch. Thanks, Kugan gcc/ 2014-06-25 Kugan Vivekanandarajah * calls.c (precompute_arguments): Check is_promoted_for_type and set the promoted mode. (is_promoted_for_type): New function. (expand_expr_real_1): Check is_promoted_for_type and set the promoted mode. * expr.h (is_promoted_for_type): New function definition. * cfgexpand.c (expand_gimple_stmt_1): Call emit_move_insn if SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED.