From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 154F138515FB; Thu, 3 Jun 2021 04:33:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 154F138515FB From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/43892] PowerPC suboptimal "add with carry" optimization Date: Thu, 03 Jun 2021 04:33:58 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.3.4 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: segher at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: segher at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: 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: Thu, 03 Jun 2021 04:34:00 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D43892 --- Comment #33 from Segher Boessenkool --- (In reply to Andrew Pinski from comment #32) > So it is more about the back-end of PowerPC at this point. For the testcase =3D=3D=3D typedef unsigned int u32; typedef unsigned long long u64; u32 f(u32 a, u32 b) { u32 s =3D a + b; if (a + b < b) s++; return s; } u32 g(u32 *p, u32 n) { u32 s =3D 0; while (n--) s =3D f(s, *p++); return s; } u32 g4(u32 *p) { u32 s =3D 0; s =3D f(s, *p++); s =3D f(s, *p++); s =3D f(s, *p++); s =3D f(s, *p++); return s; } u32 h4(u32 *p) { u64 s =3D 0; s +=3D *p++;imple s +=3D *p++; s +=3D *p++; s +=3D *p++; s =3D (s >> 32) + (u32)s; s =3D (s >> 32) + (u32)s; return s; } =3D=3D=3D ... GCC does not do anything with ADD_OVERFLOW. But all *do* compile to reasonable code (albeit not optimal). So no, you cannot say Gimple is super here and it is all the backend's fault :-)=