diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-22 09:39:41 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-22 09:39:41 +0000 |
commit | a69a910a1563215b751f1dda609a0274b645e492 (patch) | |
tree | 4d3c04a1ba5c20891e6ff625a7e0c0c52afa9b11 /gcc/fold-const.c | |
parent | 8a1586baa04be64c3347723371fbd6b8ce78a049 (diff) | |
download | gcc-a69a910a1563215b751f1dda609a0274b645e492.tar.gz |
2007-09-22 Richard Guenther <rguenther@suse.de>
PR tree-optimization/33146
* fold-const.c (fold_binary): Use the original tree
for negating.
* tree.h (STRIP_SIGN_NOPS): Converting from or to pointer
also changes "sign".
* gcc.c-torture/compile/pr33146.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128666 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fb664fee8be..426aad4ced1 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10240,9 +10240,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return omit_one_operand (type, arg1, arg0); if (integer_onep (arg1)) return non_lvalue (fold_convert (type, arg0)); - /* Transform x * -1 into -x. */ + /* Transform x * -1 into -x. Make sure to do the negation + on the original operand with conversions not stripped + because we can only strip non-sign-changing conversions. */ if (integer_all_onesp (arg1)) - return fold_convert (type, negate_expr (arg0)); + return fold_convert (type, negate_expr (op0)); /* Transform x * -C into -x * C if x is easily negatable. */ if (TREE_CODE (arg1) == INTEGER_CST && tree_int_cst_sgn (arg1) == -1 |