From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22691 invoked by alias); 18 Oct 2012 19:24:56 -0000 Received: (qmail 22636 invoked by uid 48); 18 Oct 2012 19:24:36 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54830] [SH] Unnecessary exts.w before extu.b Date: Thu, 18 Oct 2012 19:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg01705.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54830 --- Comment #1 from Oleg Endo 2012-10-18 19:24:36 UTC --- Created attachment 28487 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28487 Reduced test case This is the reduced test case. It shows that there are actually two redundant zero/sign extensions when compiling with -m4 {-ml|-mb} -O2: swap.w r5,r5 ! 88 rotlsi3_16 ... exts.w r5,r5 ! 89 *extendhisi2_compact_reg ... extu.b r5,r9 ! 10 *zero_extendqisi2_compact ... extu.b r9,r12 ! 11 *zero_extendqisi2_compact ... Turning on the REE pass (-free) doesn't seem to help this either. Adding the following pattern to sh.md: (define_insn_and_split "*" [(set (match_operand:SI 0 "register_operand") (zero_extract:SI (match_operand:SI 1 "register_operand") (const_int 8) (const_int 16)))] "TARGET_SH1" "#" "&& 1" [(set (match_dup 0) (lshiftrt:SI (match_dup 1) (const_int 16))) (set (match_dup 0) (zero_extend:SI (match_dup 2)))] { operands[2] = gen_lowpart (QImode, operands[0]); }) eliminates the first sign-extension (exts.w) only. The second zero-extension can be eliminated by extending sh_try_omit_signzero_extend in sh.c accordingly.