Commit d54ef62c by Geoffrey Keating Committed by Geoffrey Keating

ifcvt.c (noce_try_store_flag_constants): Use trunc_int_for_mode when negating constants.

	* ifcvt.c (noce_try_store_flag_constants): Use trunc_int_for_mode
	when negating constants.

From-SVN: r44158
parent 7d46d516
2001-07-19 Geoffrey Keating <geoffk@redhat.com>
* ifcvt.c (noce_try_store_flag_constants): Use trunc_int_for_mode
when negating constants.
2001-07-19 Toon Moene <toon@moene.indiv.nluug.nl> 2001-07-19 Toon Moene <toon@moene.indiv.nluug.nl>
* tree.def: Document restriction on {L|R}SHIFT_EXPR's second argument. * tree.def: Document restriction on {L|R}SHIFT_EXPR's second argument.
......
...@@ -642,14 +642,16 @@ noce_try_store_flag_constants (if_info) ...@@ -642,14 +642,16 @@ noce_try_store_flag_constants (if_info)
int reversep; int reversep;
HOST_WIDE_INT itrue, ifalse, diff, tmp; HOST_WIDE_INT itrue, ifalse, diff, tmp;
int normalize, can_reverse; int normalize, can_reverse;
enum machine_mode mode;
if (! no_new_pseudos if (! no_new_pseudos
&& GET_CODE (if_info->a) == CONST_INT && GET_CODE (if_info->a) == CONST_INT
&& GET_CODE (if_info->b) == CONST_INT) && GET_CODE (if_info->b) == CONST_INT)
{ {
mode = GET_MODE (if_info->x);
ifalse = INTVAL (if_info->a); ifalse = INTVAL (if_info->a);
itrue = INTVAL (if_info->b); itrue = INTVAL (if_info->b);
diff = itrue - ifalse; diff = trunc_int_for_mode (mode, itrue - ifalse);
can_reverse = (reversed_comparison_code (if_info->cond, if_info->jump) can_reverse = (reversed_comparison_code (if_info->cond, if_info->jump)
!= UNKNOWN); != UNKNOWN);
...@@ -680,7 +682,7 @@ noce_try_store_flag_constants (if_info) ...@@ -680,7 +682,7 @@ noce_try_store_flag_constants (if_info)
if (reversep) if (reversep)
{ {
tmp = itrue; itrue = ifalse; ifalse = tmp; tmp = itrue; itrue = ifalse; ifalse = tmp;
diff = -diff; diff = trunc_int_for_mode (mode, -diff);
} }
start_sequence (); start_sequence ();
...@@ -695,7 +697,7 @@ noce_try_store_flag_constants (if_info) ...@@ -695,7 +697,7 @@ noce_try_store_flag_constants (if_info)
=> x = 3 + (test == 0); */ => x = 3 + (test == 0); */
if (diff == STORE_FLAG_VALUE || diff == -STORE_FLAG_VALUE) if (diff == STORE_FLAG_VALUE || diff == -STORE_FLAG_VALUE)
{ {
target = expand_binop (GET_MODE (if_info->x), target = expand_binop (mode,
(diff == STORE_FLAG_VALUE (diff == STORE_FLAG_VALUE
? add_optab : sub_optab), ? add_optab : sub_optab),
GEN_INT (ifalse), target, if_info->x, 0, GEN_INT (ifalse), target, if_info->x, 0,
...@@ -706,7 +708,7 @@ noce_try_store_flag_constants (if_info) ...@@ -706,7 +708,7 @@ noce_try_store_flag_constants (if_info)
=> x = (test != 0) << 3; */ => x = (test != 0) << 3; */
else if (ifalse == 0 && (tmp = exact_log2 (itrue)) >= 0) else if (ifalse == 0 && (tmp = exact_log2 (itrue)) >= 0)
{ {
target = expand_binop (GET_MODE (if_info->x), ashl_optab, target = expand_binop (mode, ashl_optab,
target, GEN_INT (tmp), if_info->x, 0, target, GEN_INT (tmp), if_info->x, 0,
OPTAB_WIDEN); OPTAB_WIDEN);
} }
...@@ -715,7 +717,7 @@ noce_try_store_flag_constants (if_info) ...@@ -715,7 +717,7 @@ noce_try_store_flag_constants (if_info)
=> x = -(test != 0) | b; */ => x = -(test != 0) | b; */
else if (itrue == -1) else if (itrue == -1)
{ {
target = expand_binop (GET_MODE (if_info->x), ior_optab, target = expand_binop (mode, ior_optab,
target, GEN_INT (ifalse), if_info->x, 0, target, GEN_INT (ifalse), if_info->x, 0,
OPTAB_WIDEN); OPTAB_WIDEN);
} }
...@@ -724,11 +726,11 @@ noce_try_store_flag_constants (if_info) ...@@ -724,11 +726,11 @@ noce_try_store_flag_constants (if_info)
=> x = (-(test != 0) & (b - a)) + a; */ => x = (-(test != 0) & (b - a)) + a; */
else else
{ {
target = expand_binop (GET_MODE (if_info->x), and_optab, target = expand_binop (mode, and_optab,
target, GEN_INT (diff), if_info->x, 0, target, GEN_INT (diff), if_info->x, 0,
OPTAB_WIDEN); OPTAB_WIDEN);
if (target) if (target)
target = expand_binop (GET_MODE (if_info->x), add_optab, target = expand_binop (mode, add_optab,
target, GEN_INT (ifalse), if_info->x, 0, target, GEN_INT (ifalse), if_info->x, 0,
OPTAB_WIDEN); OPTAB_WIDEN);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment