You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
2.0 KiB
63 lines
2.0 KiB
17 years ago
|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
||
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
||
|
#
|
||
|
# Filename: package/.../gcc/extract_muldiv.patch
|
||
|
# Copyright (C) 2007 The OpenSDE Project
|
||
|
#
|
||
|
# More information can be found in the files COPYING and README.
|
||
|
#
|
||
|
# This patch file is dual-licensed. It is available under the license the
|
||
|
# patched project is licensed under, as long as it is an OpenSource license
|
||
|
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
|
||
|
# of the GNU General Public License as published by the Free Software
|
||
|
# Foundation; either version 2 of the License, or (at your option) any later
|
||
|
# version.
|
||
|
# --- SDE-COPYRIGHT-NOTE-END ---
|
||
|
|
||
|
Take from http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00948.html
|
||
|
|
||
|
2007-11-17 Richard Guenther <rguenther@suse.de>
|
||
|
|
||
|
PR middle-end/34130
|
||
|
* fold-const.c (extract_muldiv_1): Do not move negative
|
||
|
constants inside ABS_EXPR.
|
||
|
|
||
|
* gcc.c-torture/execute/pr34130.c: New testcase.
|
||
|
|
||
|
Index: ./gcc/fold-const.c
|
||
|
===================================================================
|
||
|
*** ./gcc/fold-const.c (revision 130238)
|
||
|
--- ./gcc/fold-const.c (working copy)
|
||
|
*************** extract_muldiv_1 (tree t, tree c, enum t
|
||
|
*** 6095,6100 ****
|
||
|
--- 6095,6103 ----
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
+ /* If the constant is negative, we cannot simplify this. */
|
||
|
+ if (tree_int_cst_sgn (c) == -1)
|
||
|
+ break;
|
||
|
/* FALLTHROUGH */
|
||
|
case NEGATE_EXPR:
|
||
|
if ((t1 = extract_muldiv (op0, c, code, wide_type, strict_overflow_p))
|
||
|
Index: ./gcc/testsuite/gcc.c-torture/execute/pr34130.c
|
||
|
===================================================================
|
||
|
*** ./gcc/testsuite/gcc.c-torture/execute/pr34130.c (revision 0)
|
||
|
--- ./gcc/testsuite/gcc.c-torture/execute/pr34130.c (revision 0)
|
||
|
***************
|
||
|
*** 0 ****
|
||
|
--- 1,12 ----
|
||
|
+ extern void abort (void);
|
||
|
+ int foo (int i)
|
||
|
+ {
|
||
|
+ return -2 * __builtin_abs(i - 2);
|
||
|
+ }
|
||
|
+ int main()
|
||
|
+ {
|
||
|
+ if (foo(1) != -2
|
||
|
+ || foo(3) != -2)
|
||
|
+ abort ();
|
||
|
+ return 0;
|
||
|
+ }
|
||
|
|