From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EC1FC3948495; Fri, 20 Mar 2020 14:16:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC1FC3948495 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1584713817; bh=g3YFLtF9HfE+wnzLmT4iX1/4C4p474ed2f24GazYCNM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f34urDx0lwqHWghmksxXHyc5rDCYV6IxDxGg9V6XWiGav/eQgK9ojuFf+hlEHPU78 YYz898hSEzI5eGrCCbrjgU7Wz30pKxLg0SZhLPSbclvSfuQTyEMSBwXILLv/CeIHNa d3czYHTCIRsieXkMqyzn6qiB8O3HizmcIFN/UWTw= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94234] missed ccp folding for (addr + 8 * n) - (addr + 8 * (n - 1)) Date: Fri, 20 Mar 2020 14:16:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed cf_reconfirmed_on keywords version bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Mar 2020 14:16:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94234 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2020-03-20 Keywords| |missed-optimization Version|unknown |10.0 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener --- Confirmed. Might be also a regression since POINTER_DIFF_EXPR introduction. We have (simplify (pointer_diff (pointer_plus @@0 @1) (pointer_plus @0 @2)) /* The second argument of pointer_plus must be interpreted as signed, a= nd thus sign-extended if necessary. */ (with { tree stype =3D signed_type_for (TREE_TYPE (@1)); } /* Use view_convert instead of convert here, as POINTER_PLUS_EXPR second arg is unsigned even when we need to consider it as signed, we don't want to diagnose overflow here. */ (minus (convert (view_convert:stype @1)) (convert (view_convert:stype @2))))))) which triggers here but appearantly the resulting minus isn't simplified. _1 =3D n_5(D) * 8; b1_7 =3D a_6(D) + _1; _2 =3D n_5(D) + 18446744073709551615; _3 =3D _2 * 8; b2_8 =3D a_6(D) + _3; and we need to simplify _1 - _3. Possibly the excessive conversions above mess with the constraint of CCP not wanting new stmts. You can see what forwprop does which applies all foldings possible and computes: _1 =3D n_5(D) * 8; _2 =3D n_5(D) + 18446744073709551615; _3 =3D _2 * 8; _11 =3D (signed long) _1; _12 =3D (signed long) _3; _4 =3D _11 - _12; _9 =3D (long unsigned int) _4; return _9; I don't think we have match.pd patterns simplifying that.=