This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR middle-end/66984 - mis-optimization of CEIL_DIV_EXPR and FLOOR_DIV_EXPR
- From: Gary Funck <gary at intrepid dot com>
- To: Gcc Patches <gcc-patches at gcc dot gnu dot org>
- Cc: rguenth at gcc dot gnu dot org
- Date: Fri, 24 Jul 2015 08:43:05 -0700
- Subject: [PATCH] Fix PR middle-end/66984 - mis-optimization of CEIL_DIV_EXPR and FLOOR_DIV_EXPR
- Authentication-results: sourceware.org; auth=none
See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66984
Confirmed that GCC trunk bootstraps without issue and
that this patch fixes the issue noted in the GUPC branch.
2015-07-24 Gary Funck <gary@intrepid.com>
PR middle-end/66984
* fold-const.c (fold_binary_loc): Call fold_convert on arguments to
fold_build2 for CEIL_DIV_EXPR and FLOOR_DIV_EXPR optimization.
Index: fold-const.c
===================================================================
--- fold-const.c (revision 226135)
+++ fold-const.c (working copy)
@@ -10804,7 +10804,9 @@ fold_binary_loc (location_t loc,
after the last round to changes to the DIV code in expmed.c. */
if ((code == CEIL_DIV_EXPR || code == FLOOR_DIV_EXPR)
&& multiple_of_p (type, arg0, arg1))
- return fold_build2_loc (loc, EXACT_DIV_EXPR, type, arg0, arg1);
+ return fold_build2_loc (loc, EXACT_DIV_EXPR, type,
+ fold_convert (type, arg0),
+ fold_convert (type, arg1));
strict_overflow_p = false;
if (TREE_CODE (arg1) == INTEGER_CST