This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
- From: "wschmidt at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 01 Aug 2017 18:23:07 +0000
- Subject: [Bug tree-optimization/81503] [8 Regression] Wrong code at -O2
- Auto-submitted: auto-generated
- References: <bug-81503-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81503
--- Comment #8 from Bill Schmidt <wschmidt at gcc dot gnu.org> ---
Patch under test that fixes this case:
Index: gcc/gimple-ssa-strength-reduction.c
===================================================================
--- gcc/gimple-ssa-strength-reduction.c (revision 250791)
+++ gcc/gimple-ssa-strength-reduction.c (working copy)
@@ -2082,6 +2082,11 @@ replace_mult_candidate (slsr_cand_t c, tree basis_
types but allows for safe negation without twisted logic. */
if (wi::fits_shwi_p (bump)
&& bump.to_shwi () != HOST_WIDE_INT_MIN
+ /* It is more likely that the bump doesn't fit in the target
+ type, so check whether constraining it to that type changes
+ the value. */
+ && wi::eq_p (TREE_INT_CST_LOW (wide_int_to_tree (target_type, bump)),
+ bump)
/* It is not useful to replace casts, copies, negates, or adds of
an SSA name and a constant. */
&& cand_code != SSA_NAME