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/55303] [SH] Add support for clips / clipu instructions Date: Sat, 02 Mar 2013 16:17:00 -0000 [thread overview] Message-ID: <bug-55303-4-JXHVviL7Gm@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-55303-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55303 Oleg Endo <olegendo at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2013-03-02 AssignedTo|unassigned at gcc dot |olegendo at gcc dot gnu.org |gnu.org | Ever Confirmed|0 |1 --- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> 2013-03-02 16:16:41 UTC --- Created attachment 29567 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29567 Working patch with a thinko. This patch, albeit working, has a thinko. The idea was to reduce the constraints of the clips/clipu insn comparison constants by adding/subtracting a constant offset value before/after the actual clipping insn. For example: int test_02 (int a) { return max (0, min (255, a)); } becomes: _test_02: movi20 #128,r1 sub r1,r4 mov r4,r0 clips.b r0 rts add r1,r0 The problem with this is that it won't work for values that will wrap-around before/after the offset subtraction/addition. E.g. plugging the value 0x80000000 (−2147483648) into the above case: movi20 #128,r1 sub r1,r4 // r4 = 0x80000000 - 128 = 0x7FFFFF80 mov r4,r0 clips.b r0 // !(r0 < -128) && (r0 > 127) -> r0 = 127 rts add r1,r0 // r0 = 127 + 128 = 255 // expected result: 0 Maybe this case could be handled by using subv/addv insns to catch over/underflows somehow, but probably the resulting code would be more complex (and thus slower) than two straight forward compare-and-branch sequences. On the other hand, if it is known that the input value is in a certain range (e.g. a sign/zero extended HImode or QImode), the offset approach should work fine. I will modify the attached patch so that it will allow only the HW clip constants for now.
next prev parent reply other threads:[~2013-03-02 16:17 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-13 0:31 [Bug target/55303] New: " olegendo at gcc dot gnu.org 2013-03-02 16:17 ` olegendo at gcc dot gnu.org [this message] 2013-03-02 16:24 ` [Bug target/55303] " olegendo at gcc dot gnu.org 2013-05-06 5:48 ` 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-55303-4-JXHVviL7Gm@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: linkBe 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).