public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/45223] RTL PRE GCSE pass hoists trapping insn out of loop
Date: Sat, 07 Aug 2010 08:34:00 -0000	[thread overview]
Message-ID: <20100807083359.21675.qmail@sourceware.org> (raw)
In-Reply-To: <bug-45223-1649@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from ubizjak at gmail dot com  2010-08-07 08:33 -------
Following patch fixes this problem:

Index: gcse.c
===================================================================
--- gcse.c      (revision 162975)
+++ gcse.c      (working copy)
@@ -1693,7 +1693,7 @@ compute_hash_table_work (struct hash_tab

       /* The next pass builds the hash table.  */
       FOR_BB_INSNS (current_bb, insn)
-       if (INSN_P (insn))
+       if (INSN_P (insn) && !may_trap_p (PATTERN (insn)))
          hash_scan_insn (insn, table);
     }


main:
        push   $sp, $r6
        push   $sp, $r7
        push   $sp, $r8
        push   $sp, $r9
        push   $sp, $r10
        push   $sp, $r11
        dec    $sp, 28
        lda.l  $r0, a
        sto.l  -28($fp), $r0
        lda.l  $r11, b
        xor    $r6, $r6
        ldi.l  $r10, foo
        ldi.l  $r8, 8
        ldi.l  $r7, 99
        jmpa   .L4
.L3:
        lda.l  $r1, r
        ldo.l  $r0, -28($fp)
        mod.l  $r0, $r11
        add.l  $r0, $r1
        add.l  $r0, $r6
        sta.l  r, $r0
        inc    $r6, 1
        cmp    $r6, $r7
        bgt   .L7
.L4:
        jsr    $r10
        lda.l  $r0, x
        cmp    $r0, $r8
        bne   .L3
        inc    $r6, 1
        lda.l  $r1, r
        ldo.l  $r0, -28($fp)
>	mod.l  $r0, $r11
        add.l  $r0, $r1
        add.l  $r0, $r6
        sta.l  r, $r0
        inc    $r6, 1
        cmp    $r6, $r7
        ble   .L4
.L7:
        jsra   abort

In a general case, I guess that if it can be proved that denominator can't be
zero we can still hoist mod.l out of the loop.


-- 


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


  reply	other threads:[~2010-08-07  8:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-07  8:24 [Bug rtl-optimization/45223] New: " ubizjak at gmail dot com
2010-08-07  8:34 ` ubizjak at gmail dot com [this message]
2010-08-07  8:40 ` [Bug rtl-optimization/45223] " ubizjak at gmail dot com
2010-08-07 10:58 ` steven at gcc dot gnu dot org
2010-08-07 11:26 ` ubizjak at gmail dot com
2010-08-07 15:27 ` ubizjak at gmail dot com
2010-08-12 14:46 ` ubizjak at gmail dot com
2010-09-04 10:03 ` ubizjak at gmail dot com
     [not found] <bug-45223-4@http.gcc.gnu.org/bugzilla/>
2021-10-11  3:44 ` pinskia at gcc dot gnu.org
2021-10-11  9:11 ` rguenth 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=20100807083359.21675.qmail@sourceware.org \
    --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).