Commit 1f0c5cc9 by Richard Stallman

(convert_to_integer): Don't pass truncation thru lshift if shift count >= width of narrower type.

(convert_to_integer): Don't pass truncation thru lshift
if shift count >= width of narrower type.  Instead, just use 0.

From-SVN: r2104
parent 4f61da45
...@@ -187,9 +187,21 @@ convert_to_integer (type, expr) ...@@ -187,9 +187,21 @@ convert_to_integer (type, expr)
/* We can pass truncation down through left shifting /* We can pass truncation down through left shifting
when the shift count is a nonnegative constant. */ when the shift count is a nonnegative constant. */
if (TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST if (TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST
&& ! tree_int_cst_lt (TREE_OPERAND (expr, 1), integer_zero_node)) && ! tree_int_cst_lt (TREE_OPERAND (expr, 1), integer_zero_node)
/* In this case, shifting is like multiplication. */ && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
goto trunc1; {
/* If shift count is less than the width of the truncated type,
really shift. */
if (tree_int_cst_lt (TREE_OPERAND (expr, 1), TYPE_SIZE (type)))
/* In this case, shifting is like multiplication. */
goto trunc1;
else
/* If it is >= that width, result is zero.
Handling this with trunc1 would give the wrong result:
(int) ((long long) a << 32) is well defined (as 0)
but (int) a << 32 is undefined and would get a warning. */
return convert_to_integer (type, integer_zero_node);
}
break; break;
case MAX_EXPR: case MAX_EXPR:
......
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