(expand_expr, case IN_EXPR): Fix numerous small bugs and make some
cleanups. From-SVN: r3541
This commit is contained in:
parent
cabeca2978
commit
17938e5781
57
gcc/expr.c
57
gcc/expr.c
|
@ -4483,7 +4483,7 @@ expand_expr (exp, target, tmode, modifier)
|
||||||
enum machine_mode index_mode = TYPE_MODE (TREE_TYPE (index));
|
enum machine_mode index_mode = TYPE_MODE (TREE_TYPE (index));
|
||||||
|
|
||||||
if (target == 0)
|
if (target == 0)
|
||||||
target = gen_reg_rtx (TYPE_MODE (TREE_TYPE (exp)));
|
target = gen_reg_rtx (mode);
|
||||||
|
|
||||||
/* If domain is empty, answer is no. */
|
/* If domain is empty, answer is no. */
|
||||||
if (tree_int_cst_lt (set_high_bound, set_low_bound))
|
if (tree_int_cst_lt (set_high_bound, set_low_bound))
|
||||||
|
@ -4497,18 +4497,14 @@ expand_expr (exp, target, tmode, modifier)
|
||||||
|
|
||||||
/* Compare index against bounds, if they are constant. */
|
/* Compare index against bounds, if they are constant. */
|
||||||
if (GET_CODE (index_val) == CONST_INT
|
if (GET_CODE (index_val) == CONST_INT
|
||||||
&& GET_CODE (lo_r) == CONST_INT)
|
&& GET_CODE (lo_r) == CONST_INT
|
||||||
{
|
&& INTVAL (index_val) < INTVAL (lo_r))
|
||||||
if (INTVAL (index_val) < INTVAL (lo_r))
|
return const0_rtx;
|
||||||
return const0_rtx;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GET_CODE (index_val) == CONST_INT
|
if (GET_CODE (index_val) == CONST_INT
|
||||||
&& GET_CODE (hi_r) == CONST_INT)
|
&& GET_CODE (hi_r) == CONST_INT
|
||||||
{
|
&& INTVAL (hi_r) < INTVAL (index_val))
|
||||||
if (INTVAL (hi_r) < INTVAL (index_val))
|
return const0_rtx;
|
||||||
return const0_rtx;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we get here, we have to generate the code for both cases
|
/* If we get here, we have to generate the code for both cases
|
||||||
(in range and out of range). */
|
(in range and out of range). */
|
||||||
|
@ -4519,46 +4515,51 @@ expand_expr (exp, target, tmode, modifier)
|
||||||
if (! (GET_CODE (index_val) == CONST_INT
|
if (! (GET_CODE (index_val) == CONST_INT
|
||||||
&& GET_CODE (lo_r) == CONST_INT))
|
&& GET_CODE (lo_r) == CONST_INT))
|
||||||
{
|
{
|
||||||
emit_cmp_insn (index_val, lo_r, LT, 0, GET_MODE (index_val), 0, 0);
|
emit_cmp_insn (index_val, lo_r, LT, NULL_RTX,
|
||||||
|
GET_MODE (index_val), 0, 0);
|
||||||
emit_jump_insn (gen_blt (op1));
|
emit_jump_insn (gen_blt (op1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (GET_CODE (index_val) == CONST_INT
|
if (! (GET_CODE (index_val) == CONST_INT
|
||||||
&& GET_CODE (hi_r) == CONST_INT))
|
&& GET_CODE (hi_r) == CONST_INT))
|
||||||
{
|
{
|
||||||
emit_cmp_insn (index_val, hi_r, GT, 0, GET_MODE (index_val), 0, 0);
|
emit_cmp_insn (index_val, hi_r, GT, NULL_RTX,
|
||||||
|
GET_MODE (index_val), 0, 0);
|
||||||
emit_jump_insn (gen_bgt (op1));
|
emit_jump_insn (gen_bgt (op1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the element number of bit zero in the first word
|
/* Calculate the element number of bit zero in the first word
|
||||||
of the set. */
|
of the set. */
|
||||||
if (GET_CODE (lo_r) == CONST_INT)
|
if (GET_CODE (lo_r) == CONST_INT)
|
||||||
rlow = gen_rtx (CONST_INT, VOIDmode,
|
rlow = GEN_INT (INTVAL (lo_r)
|
||||||
INTVAL (lo_r) & ~ (1 << BITS_PER_UNIT));
|
& ~ ((HOST_WIDE_INT) 1 << BITS_PER_UNIT));
|
||||||
else
|
else
|
||||||
rlow = expand_binop (index_mode, and_optab,
|
rlow = expand_binop (index_mode, and_optab, lo_r,
|
||||||
lo_r, gen_rtx (CONST_INT, VOIDmode,
|
GEN_INT (~((HOST_WIDE_INT) 1 << BITS_PER_UNIT)),
|
||||||
~ (1 << BITS_PER_UNIT)),
|
NULL_RTX, 0, OPTAB_LIB_WIDEN);
|
||||||
0, 0, OPTAB_LIB_WIDEN);
|
|
||||||
|
|
||||||
diff = expand_binop (index_mode, sub_optab,
|
diff = expand_binop (index_mode, sub_optab,
|
||||||
index_val, rlow, 0, 0, OPTAB_LIB_WIDEN);
|
index_val, rlow, NULL_RTX, 0, OPTAB_LIB_WIDEN);
|
||||||
|
|
||||||
quo = expand_divmod (0, TRUNC_DIV_EXPR, index_mode, diff,
|
quo = expand_divmod (0, TRUNC_DIV_EXPR, index_mode, diff,
|
||||||
gen_rtx (CONST_INT, VOIDmode, BITS_PER_UNIT),
|
GEN_INT (BITS_PER_UNIT), NULL_RTX, 0);
|
||||||
0, 0);
|
|
||||||
rem = expand_divmod (1, TRUNC_MOD_EXPR, index_mode, index_val,
|
rem = expand_divmod (1, TRUNC_MOD_EXPR, index_mode, index_val,
|
||||||
gen_rtx (CONST_INT, VOIDmode, BITS_PER_UNIT),
|
GEN_INT (BITS_PER_UNIT), NULL_RTX, 0);
|
||||||
0, 0);
|
|
||||||
addr = memory_address (byte_mode,
|
addr = memory_address (byte_mode,
|
||||||
expand_binop (index_mode, add_optab,
|
expand_binop (index_mode, add_optab,
|
||||||
diff, setaddr));
|
diff, setaddr, NULL_RTX, 0,
|
||||||
|
OPTAB_LIB_WIDEN));
|
||||||
/* Extract the bit we want to examine */
|
/* Extract the bit we want to examine */
|
||||||
bit = expand_shift (RSHIFT_EXPR, byte_mode,
|
bit = expand_shift (RSHIFT_EXPR, byte_mode,
|
||||||
gen_rtx (MEM, byte_mode, addr), rem, 0, 1);
|
gen_rtx (MEM, byte_mode, addr),
|
||||||
result = expand_binop (SImode, and_optab, bit, const1_rtx, target,
|
make_tree (TREE_TYPE (index), rem),
|
||||||
|
NULL_RTX, 1);
|
||||||
|
result = expand_binop (byte_mode, and_optab, bit, const1_rtx,
|
||||||
|
GET_MODE (target) == byte_mode ? target : 0,
|
||||||
1, OPTAB_LIB_WIDEN);
|
1, OPTAB_LIB_WIDEN);
|
||||||
emit_move_insn (target, result);
|
|
||||||
|
if (result != target)
|
||||||
|
convert_move (target, result, 1);
|
||||||
|
|
||||||
/* Output the code to handle the out-of-range case. */
|
/* Output the code to handle the out-of-range case. */
|
||||||
emit_jump (op0);
|
emit_jump (op0);
|
||||||
|
|
Loading…
Reference in New Issue