From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 874B93858C74; Sun, 28 May 2023 10:48:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 874B93858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685270896; bh=rE+E//nTwrsVUFM7tA5yLbzGzYR6xvznUUJbMXp2vMY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bRBaWW2G5KyPNqzrV46xznfXVXVUzBPRPPhBnsMVA3AKQB1FtkagpxwSknfsTM0IU QuKbANAN5pRyDt+LOnLl0Vzzu56saghdiBu43SQqeXQEBoNh2ybVoMJ6a2hQAF9Hxg 3HirI9Sqajt5ES+zoXWUpDvB7pjNrwg18BZjA6/w= From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/49263] SH Target: underutilized "TST #imm, R0" instruction Date: Sun, 28 May 2023 10:48:16 +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.6.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: olegendo 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D49263 --- Comment #44 from Oleg Endo --- (In reply to Alexander Klepikov from comment #43) >=20 > Well, not really. Look what's happening during expand pass when 'ashrsi3'= is > expanding. Function 'expand_ashiftrt' is called and what it does at the e= nd > - it explicitly emits 3 insns: > [...] >=20 > By the way, right shift for integers expands to only one 'lshiftrt' insn = and > that's why it can be catched and converted to 'tst'. >=20 Yeah, I might have dropped the ball on the right shift patterns back then a= nd only reworked the left shift patterns to do that.=20 >=20 > As far as I understand these insns could be catched later by a peephole a= nd > converted to 'tstsi_t' insn like it is done for other much simple insn > sequences. It's the combine RTL pass and split1 RTL pass that does most of this work h= ere. Peephole pass in GCC is too simplistic for this. >=20 > Thank you for your time and detailed explanations! I agree with you on all > points. Software cannot be perfect and it's OK for GCC not to be super > optimized, so this part better sholud be left intact. We can't have it perfect, but we can try ;) >=20 > By the way, I tried to link library to my project and I figured out that > linker is smart enough to link only necessary library functions even with= out > LTO. So increase in size is about 100 or 200 bytes, that is acceptable. > Thank you very much for help! You're welcome. Yes, to strip out unused library functions it doesn't need LTO. But using = LTO for embedded/MCU firmware, I find it can reduce the code size by about 20%= .=20 For example, it can also inline small library functions in your code (if the library was also compiled with LTO).=