Commit 2c0eba5a by Jakub Jelinek Committed by Jakub Jelinek

re PR c/39855 (Shift optimization discards operands' side effects)

	PR c/39855
	* fold-const.c (fold_binary) <case LSHIFT_EXPR>: When optimizing
	into 0, use omit_one_operand.

	* gcc.dg/torture/pr39855.c: New test.

From-SVN: r146617
parent 023f059b
......@@ -3,6 +3,10 @@
* alias.c (find_base_term): Move around LO_SUM case, so that
CONST falls through into PLUS/MINUS handling.
PR c/39855
* fold-const.c (fold_binary) <case LSHIFT_EXPR>: When optimizing
into 0, use omit_one_operand.
2009-04-23 Ben Elliston <bje@au.ibm.com>
* config/rs6000/linux-unwind.h (get_regs): Remove type
......
......@@ -11880,7 +11880,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
if (code == LROTATE_EXPR || code == RROTATE_EXPR)
low = low % TYPE_PRECISION (type);
else if (TYPE_UNSIGNED (type) || code == LSHIFT_EXPR)
return build_int_cst (type, 0);
return omit_one_operand (type, build_int_cst (type, 0),
TREE_OPERAND (arg0, 0));
else
low = TYPE_PRECISION (type) - 1;
}
......
2009-04-22 Jakub Jelinek <jakub@redhat.com>
PR c/39855
* gcc.dg/torture/pr39855.c: New test.
2009-04-22 Dodji Seketeli <dodji@redhat.com>
PR c++/39639
......
/* PR c/39855 */
/* { dg-do run { target { int32plus } } } */
extern void abort (void);
int i, j, k;
int
foo (void)
{
return ++i;
}
int
main ()
{
if (__CHAR_BIT__ != 8 || sizeof (int) != 4)
return 0;
j = foo () << 30 << 2;
k = (unsigned) foo () >> 16 >> 16;
if (i != 2 || j != 0 || k != 0)
abort ();
return 0;
}
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