[PATCH v3, c]: Fix PR c/39779, ICE shifting byte to the right with constant > 7FFFFFFF

Uros Bizjak ubizjak@gmail.com
Mon Sep 21 14:09:00 GMT 2009


On Mon, Sep 21, 2009 at 3:31 PM, Uros Bizjak <ubizjak@gmail.com> wrote:

> This patch ensures that integer constant fits smaller type.
> "short_shift" is set when integer constant > 0 by checking the sign
> with tree_int_cst_sgn, and when "short_shift" is used, we re-check op1
> with "compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0".
> For some reason, tree_int_cst_sgn and compare_tree_int don't agree on
> signedness of op1, leading to (kind of) invalid conversion of huge
> negative value from QImode to QImode.

Well, we have:

	  /* Convert the shift-count to an integer, regardless of size
	     of value being shifted.  */
	  if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
	    op1 = convert (integer_type_node, op1);

in between calls to tree_int_cst_sgn and compare_tree_int, so this
fact clears the magic...

Uros.



More information about the Gcc-patches mailing list