Commit e0f1be5c by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/5877 (negative offset to array index leads to inefficient code)


	PR middle-end/5877
	* expr.c (highest_pow2_factor): Check TREE_INT_CST_LOW
	even for non-representable constants.

From-SVN: r50495
parent 93fe8e92
2002-03-09 Jakub Jelinek <jakub@redhat.com>
PR middle-end/5877
* expr.c (highest_pow2_factor): Check TREE_INT_CST_LOW
even for non-representable constants.
Sat Mar 9 07:20:01 2002 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> Sat Mar 9 07:20:01 2002 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* emit-rtl.c (copy_most_rtx): Accept EXPR_LIST for may_share. * emit-rtl.c (copy_most_rtx): Accept EXPR_LIST for may_share.
......
...@@ -5827,20 +5827,21 @@ highest_pow2_factor (exp) ...@@ -5827,20 +5827,21 @@ highest_pow2_factor (exp)
switch (TREE_CODE (exp)) switch (TREE_CODE (exp))
{ {
case INTEGER_CST: case INTEGER_CST:
/* If the integer is expressable in a HOST_WIDE_INT, we can find the /* We can find the lowest bit that's a one. If the low
lowest bit that's a one. If the result is zero, return HOST_BITS_PER_WIDE_INT bits are zero, return BIGGEST_ALIGNMENT.
BIGGEST_ALIGNMENT. We need to handle this case since we can find it We need to handle this case since we can find it in a COND_EXPR,
in a COND_EXPR, a MIN_EXPR, or a MAX_EXPR. If the constant overlows, a MIN_EXPR, or a MAX_EXPR. If the constant overlows, we have an
we have an erroneous program, so return BIGGEST_ALIGNMENT to avoid any erroneous program, so return BIGGEST_ALIGNMENT to avoid any
later ICE. */ later ICE. */
if (TREE_CONSTANT_OVERFLOW (exp) if (TREE_CONSTANT_OVERFLOW (exp))
|| integer_zerop (exp))
return BIGGEST_ALIGNMENT; return BIGGEST_ALIGNMENT;
else if (host_integerp (exp, 0)) else
{ {
c0 = tree_low_cst (exp, 0); /* Note: tree_low_cst is intentionally not used here,
c0 = c0 < 0 ? - c0 : c0; we don't care about the upper bits. */
return c0 & -c0; c0 = TREE_INT_CST_LOW (exp);
c0 &= -c0;
return c0 ? c0 : BIGGEST_ALIGNMENT;
} }
break; break;
......
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