From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D5F50388C014; Sun, 21 Jun 2020 16:30:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5F50388C014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1592757041; bh=0UVtuBcLEfAZgZdvS2Eirgftart3Q1zI7RyfI9m7E1s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=piDQuUqlqiQE+OHTGsRHKqRkh7CcUgo9tlcNN6Tdbo9KpuheHHKh3VkWPqpbz2gT3 1hJuIOO2vXfuYtzSPy9mI9ppT9TduoKlNy213j18icI0AExqKeNXIHgRjemyhzBhhd B+8a7q64ZChH2GIszxZtNrwsOpptK/0fIne4Fs1A= From: "segher at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95737] PPC: Unnecessary extsw after negative less than Date: Sun, 21 Jun 2020 16:30:41 +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: 8.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal 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: assigned_to cc cf_gcctarget everconfirmed bug_status cf_reconfirmed_on 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: Sun, 21 Jun 2020 16:30:41 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95737 Segher Boessenkool changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |segher at gcc dot g= nu.org CC| |segher at gcc dot gnu.org Target|powerpc-*-*-* |powerpc64*-*-* Ever confirmed|0 |1 Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2020-06-21 --- Comment #5 from Segher Boessenkool --- In gimple this already is negativeLessThan (long long unsigned int a, long long unsigned int b) { _Bool _1; int _2; int _3; long long unsigned int _6; _1 =3D a_4(D) < b_5(D); _2 =3D (int) _1; _3 =3D -_2; _6 =3D (long long unsigned int) _3; return _6; } Then, it is expanded as a sign_extend:DI of a subreg:SI, and nowhere does it see this isn't necessary (it isn't because that SI cannot be negative). The RTL code isn't optimised very well before combine, and that does Trying 11 -> 12: 11: {r128:SI=3Dca:SI-0x1;clobber ca:SI;} REG_UNUSED ca:SI 12: r123:DI=3Dsign_extend(r128:SI) REG_DEAD r128:SI Failed to match this instruction: (set (reg:DI 123) (sign_extend:DI (plus:SI (reg:SI 98 ca [+4 ]) (const_int -1 [0xffffffffffffffff])))) (note everything is made SImode in insn 11 before, it absorbed the subreg). Combine cannot keep track of known zero bits of hard regs well, so it fails to see that XER[CA] is only ever 0 or 1 here (it always is, but it doesn't know that either). I'll try to add an extra pattern for this extend, that will do the trick I think.=