This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR27116, revert patch for PR23669
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 7 Jun 2006 17:42:05 +0200 (CEST)
- Subject: [PATCH] Fix PR27116, revert patch for PR23669
Reverting the (wrong) patch for PR23669 fixes the miscompilation in
PR27116.
Bootstrapped and tested (some time ago) on x86_64-unknown-linux-gnu.
Ok for mainline?
Thanks,
Richard.
:ADDPATCH middle-end:
2006-06-07 Richard Guenther <rguenther@suse.de>
Revert
2005-11-26 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/23669
* fold-const.c (fold_binary): Convert -A/-B to A/B for signed types
when overflow is undefined.
* gcc.dg/tree-ssa/divide-1.c: New test.
* gcc.dg/tree-ssa/divide-2.c: New test.
Index: gcc/fold-const.c
===================================================================
*** gcc/fold-const.c (revision 107543)
--- gcc/fold-const.c (revision 107542)
*************** fold_binary (enum tree_code code, tree t
*** 8440,8458 ****
&& TREE_INT_CST_HIGH (arg1) == -1)
return fold_convert (type, negate_expr (arg0));
- /* Convert -A / -B to A / B when the type is signed and overflow is
- undefined. */
- if (!TYPE_UNSIGNED (type) && !flag_wrapv
- && TREE_CODE (arg0) == NEGATE_EXPR
- && negate_expr_p (arg1))
- return fold_build2 (code, type, TREE_OPERAND (arg0, 0),
- negate_expr (arg1));
- if (!TYPE_UNSIGNED (type) && !flag_wrapv
- && TREE_CODE (arg1) == NEGATE_EXPR
- && negate_expr_p (arg0))
- return fold_build2 (code, type, negate_expr (arg0),
- TREE_OPERAND (arg1, 0));
-
/* If arg0 is a multiple of arg1, then rewrite to the fastest div
operation, EXACT_DIV_EXPR.
--- 8440,8445 ----
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/divide-1.c (revision 107543)
--- gcc/testsuite/gcc.dg/tree-ssa/divide-1.c (revision 107542)
***************
*** 1,14 ****
- /* { dg-do compile } */
- /* { dg-options "-O1 -fdump-tree-optimized" } */
-
- int f(int a)
- {
- return (-a)/10;
- }
-
-
- /* { dg-final { scan-tree-dump-times "-a / 10" 0 "optimized"} } */
- /* { dg-final { scan-tree-dump-times "a / -10" 1 "optimized"} } */
-
- /* { dg-final { cleanup-tree-dump "optimized" } } */
-
--- 0 ----
Index: gcc/testsuite/gcc.dg/tree-ssa/divide-2.c
===================================================================
*** gcc/testsuite/gcc.dg/tree-ssa/divide-2.c (revision 107543)
--- gcc/testsuite/gcc.dg/tree-ssa/divide-2.c (revision 107542)
***************
*** 1,14 ****
- /* { dg-do compile } */
- /* { dg-options "-O1 -fdump-tree-optimized" } */
-
- int f(int a)
- {
- return 10/-a;
- }
-
-
- /* { dg-final { scan-tree-dump-times "10 / -a" 0 "optimized"} } */
- /* { dg-final { scan-tree-dump-times "-10 / a" 1 "optimized"} } */
-
- /* { dg-final { cleanup-tree-dump "optimized" } } */
-
--- 0 ----