public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "joey.ye at arm dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/54742] Switch elimination in FSM loop
Date: Mon, 17 Feb 2014 10:07:00 -0000	[thread overview]
Message-ID: <bug-54742-4-dOrN4GhooS@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-54742-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #35 from Joey Ye <joey.ye at arm dot com> ---
Here is good expansion:
;; _41 = _42 * 4;

(insn 20 19 0 (set (reg:SI 126 [ D.5038 ])
        (ashift:SI (reg/v:SI 131 [ Int_1_Par_Val ])
            (const_int 2 [0x2]))) -1
     (nil))

;; _40 = _2 + _41;

(insn 21 20 22 (set (reg:SI 136 [ D.5035 ])
        (plus:SI (reg/v/f:SI 130 [ Arr_2_Par_Ref ])
            (reg:SI 119 [ D.5036 ]))) -1
     (nil))

(insn 22 21 0 (set (reg/f:SI 125 [ D.5035 ])
        (plus:SI (reg:SI 136 [ D.5035 ])
            (reg:SI 126 [ D.5038 ]))) -1
     (nil))


;; MEM[(int[25] *)_51 + 20B] = _34;

(insn 29 28 30 (set (reg:SI 139)
        (plus:SI (reg/v/f:SI 130 [ Arr_2_Par_Ref ])
            (reg:SI 119 [ D.5036 ]))) Proc_8.c:23 -1
     (nil))

(insn 30 29 31 (set (reg:SI 140)
        (plus:SI (reg:SI 139)
            (reg:SI 126 [ D.5038 ]))) Proc_8.c:23 -1
     (nil))

(insn 31 30 32 (set (reg/f:SI 141)
        (plus:SI (reg:SI 140)
            (const_int 1000 [0x3e8]))) Proc_8.c:23 -1
     (nil))

(insn 32 31 0 (set (mem:SI (plus:SI (reg/f:SI 141)
                (const_int 20 [0x14])) [2 MEM[(int[25] *)_51 + 20B]+0 S4 A32])
        (reg:SI 124 [ D.5039 ])) Proc_8.c:23 -1
     (nil))

After cse1 140 can be replaced by 125, thus lead a series of transformation
make it much more efficient.

Here is bad expansion:
;; _40 = Arr_2_Par_Ref_22(D) + _12;

(insn 22 21 23 (set (reg:SI 138 [ D.5038 ])
        (plus:SI (reg:SI 128 [ D.5038 ])
            (reg:SI 121 [ D.5036 ]))) -1
     (nil))

(insn 23 22 0 (set (reg/f:SI 127 [ D.5035 ])
        (plus:SI (reg/v/f:SI 132 [ Arr_2_Par_Ref ])
            (reg:SI 138 [ D.5038 ]))) -1
     (nil))

;; _32 = _20 + 1000;

(insn 29 28 0 (set (reg:SI 124 [ D.5038 ])
        (plus:SI (reg:SI 121 [ D.5036 ])
            (const_int 1000 [0x3e8]))) Proc_8.c:23 -1
     (nil))

;; MEM[(int[25] *)_51 + 20B] = _34;

(insn 32 31 33 (set (reg:SI 141)
        (plus:SI (reg/v/f:SI 132 [ Arr_2_Par_Ref ])
            (reg:SI 124 [ D.5038 ]))) Proc_8.c:23 -1
     (nil))

(insn 33 32 34 (set (reg/f:SI 142)
        (plus:SI (reg:SI 141)
            (reg:SI 128 [ D.5038 ]))) Proc_8.c:23 -1
     (nil))

(insn 34 33 0 (set (mem:SI (plus:SI (reg/f:SI 142)
                (const_int 20 [0x14])) [2 MEM[(int[25] *)_51 + 20B]+0 S4 A32])
        (reg:SI 126 [ D.5039 ])) Proc_8.c:23 -1
     (nil))

Here cse doesn't happen, resulting in less optimal insns. Reason why cse
doesn't happen is unclear yet.


  parent reply	other threads:[~2014-02-17 10:07 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-29  3:16 [Bug tree-optimization/54742] New: " joey.ye at arm dot com
2012-09-29  3:21 ` [Bug tree-optimization/54742] " pinskia at gcc dot gnu.org
2012-10-01 10:19 ` rguenth at gcc dot gnu.org
2012-10-10  7:37 ` joey.ye at arm dot com
2013-02-19 10:27 ` rguenth at gcc dot gnu.org
2013-03-04  8:27 ` venkataramanan.kumar at amd dot com
2013-03-04  8:34 ` venkataramanan.kumar at amd dot com
2013-03-04 16:56 ` law at redhat dot com
2013-03-08  3:56 ` joey.ye at arm dot com
2013-05-02  0:11 ` sje at gcc dot gnu.org
2013-11-20  7:23 ` law at redhat dot com
2013-11-20  7:23 ` StaffLeavers at arm dot com
2013-11-20  7:24 ` StaffLeavers at arm dot com
2013-11-20  7:25 ` StaffLeavers at arm dot com
2013-11-20  7:26 ` StaffLeavers at arm dot com
2013-11-20  7:26 ` StaffLeavers at arm dot com
2013-11-20  7:26 ` StaffLeavers at arm dot com
2013-11-20  7:26 ` StaffLeavers at arm dot com
2013-11-20  7:27 ` StaffLeavers at arm dot com
2013-11-20  7:27 ` StaffLeavers at arm dot com
2013-11-20  7:28 ` StaffLeavers at arm dot com
2013-11-20  7:28 ` StaffLeavers at arm dot com
2013-11-20  7:28 ` StaffLeavers at arm dot com
2013-11-20  7:29 ` StaffLeavers at arm dot com
2013-11-20  7:31 ` StaffLeavers at arm dot com
2013-11-22 19:30 ` law at redhat dot com
2013-11-27 12:11 ` jgreenhalgh at gcc dot gnu.org
2013-11-27 12:15 ` jgreenhalgh at gcc dot gnu.org
2013-12-11 18:43 ` izamyatin at gmail dot com
2013-12-11 18:48 ` law at redhat dot com
2013-12-12 11:22 ` izamyatin at gmail dot com
2013-12-13 11:05 ` rguenth at gcc dot gnu.org
2013-12-25 13:48 ` izamyatin at gmail dot com
2014-02-17 10:07 ` joey.ye at arm dot com [this message]
2014-02-19 11:22 ` joey.ye at arm dot com
2014-06-28 15:45 ` spop at gcc dot gnu.org
2014-08-12 22:49 ` sje at gcc dot gnu.org
2014-12-06 19:20 ` spop at gcc dot gnu.org
2014-12-06 19:23 ` spop at gcc dot gnu.org
2015-01-14 10:23 ` yroux at gcc dot gnu.org
2023-12-15 18:21 ` pinskia 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-54742-4-dOrN4GhooS@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).