From 2c0eba5af00a2544e7e15bd8052a53bdb2b6f22f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 22 Apr 2009 23:57:52 +0200 Subject: re PR c/39855 (Shift optimization discards operands' side effects) PR c/39855 * fold-const.c (fold_binary) : When optimizing into 0, use omit_one_operand. * gcc.dg/torture/pr39855.c: New test. From-SVN: r146617 --- gcc/fold-const.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fold-const.c') diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ca07cf1..f0ff5b6 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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; } -- cgit v1.1