public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>,
	Richard Biener <rguenther@suse.de>,
	Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Improve RTL ifcvt for empty else_bb (PR rtl-optimization/80491)
Date: Fri, 28 Apr 2017 18:46:00 -0000	[thread overview]
Message-ID: <b38f5f19-6ed8-67f5-0428-52d8734889ea@redhat.com> (raw)
In-Reply-To: <20170425193100.GK1809@tucnak>

On 04/25/2017 01:31 PM, Jakub Jelinek wrote:
> Hi!
> 
> The following patch is a partial fix for PR80491, an improvement for
> if-conversion if there is empty else_bb.
> 
> What we do right now is in that case we only look at the immediately
> preceeding (non-debug/non-note) instruction before cond_earliest
> and if it is not the set of x, we just turn it into attempt to
> use previous value of x rather than whatever it has been initialized to.
> 
> On the testcases from the PR, we have:
> (insn 7 4 8 2 (set (reg:DI 97 [ _15+8 ])
>          (const_int 0 [0])) 81 {*movdi_internal}
>       (nil))
> (insn 8 7 9 2 (set (reg:DI 104 [ a_11(D)->low ])
>          (mem:DI (reg/v/f:DI 101 [ a ]) [2 a_11(D)->low+0 S8 A64])) 81 {*movdi_internal}
>       (nil))
> (insn 9 8 10 2 (set (reg:DI 105 [ b_12(D)->low ])
>          (mem:DI (reg/v/f:DI 102 [ b ]) [2 b_12(D)->low+0 S8 A64])) 81 {*movdi_internal}
>       (nil))
> (insn 10 9 11 2 (parallel [
>              (set (reg:CCC 17 flags)
>                  (compare:CCC (plus:DI (reg:DI 104 [ a_11(D)->low ])
>                          (reg:DI 105 [ b_12(D)->low ]))
>                      (reg:DI 104 [ a_11(D)->low ])))
>              (set (reg:DI 103)
>                  (plus:DI (reg:DI 104 [ a_11(D)->low ])
>                      (reg:DI 105 [ b_12(D)->low ])))
>          ]) 316 {*adddi3_cc_overflow_1}
>       (expr_list:REG_DEAD (reg:DI 105 [ b_12(D)->low ])
>          (expr_list:REG_DEAD (reg:DI 104 [ a_11(D)->low ])
>              (nil))))
> (jump_insn 11 10 14 2 (set (pc)
>          (if_then_else (ltu (reg:CCC 17 flags)
>                  (const_int 0 [0]))
>              (label_ref 14)
>              (pc))) 617 {*jcc_1}
>       (expr_list:REG_DEAD (reg:CCC 17 flags)
>          (int_list:REG_BR_PROB 4 (nil)))
>   -> 14)
> (code_label 14 11 35 3 3 (nil) [1 uses])
> (note 35 14 15 3 [bb 3] NOTE_INSN_BASIC_BLOCK)
> (insn 15 35 16 3 (set (reg:DI 97 [ _15+8 ])
>          (const_int 1 [0x1])) 81 {*movdi_internal}
>       (nil))
> (code_label 16 15 36 4 2 (nil) [0 uses])
> If insn 7 would come after insn 9 (which doesn't change the behavior, as
> insn 8 and insn 9 don't clobber pseudo 97 and const_int 0 is constant),
> we'd turn that into a setcc pattern, but otherwise we fail.
> 
> This patch let us search for x's setter earlier in the bb.
> During testing I found that modified_in_p/modified_in_between_p don't
> actually take into account calls that could change MEMs, so the patch
> handles that too.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> During bootstrap/regtest it seems to trigger over 10000 times, but
> my statistics collection only noted cases where it found an earlier setter
> and the noce_process_if_block has been successful, has not attempted to
> check if insn_b/set_b was NULL whether it would otherwise fail (but even
> in cases where it doesn't fail perhaps with the patch it can generate
> better code).
> 
> 2017-04-25  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR rtl-optimization/80491
> 	* ifcvt.c (noce_process_if_block): When looking for x setter
> 	with missing else_bb, don't check only the insn right before
> 	cond_earliest, but look for the last insn that x is modified in
> 	within the same bb.
OK.

jeff

      parent reply	other threads:[~2017-04-28 18:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-25 20:01 Jakub Jelinek
2017-04-26 11:57 ` Jakub Jelinek
2017-04-28 18:51   ` Jeff Law
2017-04-29 17:22     ` Jakub Jelinek
2017-04-29 22:23   ` Steven Bosscher
2017-04-30  9:13     ` Jakub Jelinek
2017-04-28 18:46 ` Jeff Law [this message]

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=b38f5f19-6ed8-67f5-0428-52d8734889ea@redhat.com \
    --to=law@redhat.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=rguenther@suse.de \
    /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).