public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-54830-4-888oPHy1TL@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54830-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54830

--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> 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.


  reply	other threads:[~2012-10-18 19:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-06  0:04 [Bug target/54830] New: " olegendo at gcc dot gnu.org
2012-10-18 19:24 ` olegendo at gcc dot gnu.org [this message]
2012-10-18 19:25 ` [Bug target/54830] " olegendo at gcc dot gnu.org
2012-11-07 21:27 ` olegendo at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54830-4-888oPHy1TL@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).