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: r146622
This commit is contained in:
parent
031828f46e
commit
82ec928fcd
|
@ -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-22 Vladimir Makarov <vmakarov@redhat.com>
|
||||
|
||||
PR rtl-optimization/39762
|
||||
|
|
|
@ -11861,7 +11861,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;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2009-04-22 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/39855
|
||||
* gcc.dg/torture/pr39855.c: New test.
|
||||
|
||||
2009-04-22 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/39824
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
/* 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;
|
||||
}
|
Loading…
Reference in New Issue