public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass
@ 2011-10-08 10:23 amker.cheng at gmail dot com
  2011-10-08 10:25 ` [Bug rtl-optimization/50663] " amker.cheng at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: amker.cheng at gmail dot com @ 2011-10-08 10:23 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50663
           Summary: conditional propagation missed in cprop.c pass
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: amker.cheng@gmail.com


For following test case:
extern int g;
int main(int a, int b)
{
    if (a == 1)
    {
        b = a;
    }

    g = b;
    return 0;
}

piece of dump file for cprop1 pass is like:


(insn 8 4 9 2 (set (reg:CC 24 cc)
        (compare:CC (reg/v:SI 135 [ a ])
            (const_int 1 [0x1]))) test.c:4 200 {*arm_cmpsi_insn}
     (nil))

(jump_insn 9 8 10 2 (set (pc)
        (if_then_else (ne (reg:CC 24 cc)
                (const_int 0 [0]))
            (label_ref 11)
            (pc))) test.c:4 212 {*arm_cond_branch}
     (expr_list:REG_DEAD (reg:CC 24 cc)
        (expr_list:REG_BR_PROB (const_int 6218 [0x184a])
            (nil)))
 -> 11)

(note 10 9 5 3 [bb 3] NOTE_INSN_BASIC_BLOCK)

(insn 5 10 11 3 (set (reg/v:SI 136 [ b ])
        (reg/v:SI 135 [ a ])) test.c:4 696 {*thumb2_movsi_insn}
     (expr_list:REG_DEAD (reg/v:SI 135 [ a ])
        (expr_list:REG_EQUAL (const_int 1 [0x1])
            (nil))))

The r135 in insn_5 should handled by conditional propagation, like:

(note 10 9 5 3 [bb 3] NOTE_INSN_BASIC_BLOCK)

(insn 5 10 11 3 (set (reg/v:SI 136 [ b ])
        (const_int 1 [0x1])) test.c:4 709 {*thumb2_movsi_insn}
     (expr_list:REG_DEAD (reg/v:SI 135 [ a ])
        (expr_list:REG_EQUAL (const_int 1 [0x1])
            (nil))))

Seems cprop misses the conditional propagation for the branch basic block.
FYI, I compiled the test case with command:
./arm-none-eabi-gcc -march=armv7-m -mthumb -O2 -S test.c -o test.S -da

The gcc is comfigured for arm-none-eabi and it's on trunk.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/50663] conditional propagation missed in cprop.c pass
  2011-10-08 10:23 [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass amker.cheng at gmail dot com
@ 2011-10-08 10:25 ` amker.cheng at gmail dot com
  2011-10-10 20:48 ` steven at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: amker.cheng at gmail dot com @ 2011-10-08 10:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from amker.cheng <amker.cheng at gmail dot com> 2011-10-08 10:25:04 UTC ---
Here comes the cause:

Though the cprop.c pass collected the implicit_set information, it is recorded
as local info of basic block, and cprop only does global propagation.
The result is such conditional const propagation opportunities is missed.

The whole process in cprop pass is like:

bb0 : if (x)
then
 bb1
else
 bb2
end

1, implicit_set from the preceding bb0 is tagged as local in bb1;
2, in compute_local_properties, the implicit_set is recorded in avloc[bb1];
3, in compute_cprop_available, the implicit_set is only recorded in avout[bb1],
   not in avin[bb1], which it should be;
4, in cprop_insn and find_avail_set, only info recorded in avin[bb1] is
considered
   when try to do propagation for bb1;

Well, I believe it is a small problem, since implicit_set is recorded
in avout[bb1],
The basic block bb1 is the only one get missed in propagation.

I'm working on a patch and will send it for reviewing later.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/50663] conditional propagation missed in cprop.c pass
  2011-10-08 10:23 [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass amker.cheng at gmail dot com
  2011-10-08 10:25 ` [Bug rtl-optimization/50663] " amker.cheng at gmail dot com
@ 2011-10-10 20:48 ` steven at gcc dot gnu.org
  2011-11-17 17:22 ` ebotcazou at gcc dot gnu.org
  2011-11-17 17:34 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: steven at gcc dot gnu.org @ 2011-10-10 20:48 UTC (permalink / raw)
  To: gcc-bugs

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

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-10-10
                 CC|                            |steven at gcc dot gnu.org
     Ever Confirmed|0                           |1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/50663] conditional propagation missed in cprop.c pass
  2011-10-08 10:23 [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass amker.cheng at gmail dot com
  2011-10-08 10:25 ` [Bug rtl-optimization/50663] " amker.cheng at gmail dot com
  2011-10-10 20:48 ` steven at gcc dot gnu.org
@ 2011-11-17 17:22 ` ebotcazou at gcc dot gnu.org
  2011-11-17 17:34 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-17 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-17 17:11:30 UTC ---
Author: ebotcazou
Date: Thu Nov 17 17:11:16 2011
New Revision: 181446

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181446
Log:
    PR rtl-optimization/50663
    * cprop.c (implicit_set_indexes): New global variable.
    (insert_set_in_table): Add additional parameter and record implicit
    set information.
    (hash_scan_set): Add additional parameter and pass it to above.
    (hash_scan_insn): Pass false to hash_scan_set.
    (compute_hash_table_work): Pass true to hash_scan_set.
    (compute_cprop_data): Add implicit set to AVIN of block which the
    implicit set is recorded for.
    (one_cprop_pass): Handle implicit_set_indexes array.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cprop.c


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug rtl-optimization/50663] conditional propagation missed in cprop.c pass
  2011-10-08 10:23 [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass amker.cheng at gmail dot com
                   ` (2 preceding siblings ...)
  2011-11-17 17:22 ` ebotcazou at gcc dot gnu.org
@ 2011-11-17 17:34 ` ebotcazou at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-17 17:34 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ebotcazou at gcc dot
                   |                            |gnu.org
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-17 17:14:39 UTC ---
Patch installed.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-17 17:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-08 10:23 [Bug rtl-optimization/50663] New: conditional propagation missed in cprop.c pass amker.cheng at gmail dot com
2011-10-08 10:25 ` [Bug rtl-optimization/50663] " amker.cheng at gmail dot com
2011-10-10 20:48 ` steven at gcc dot gnu.org
2011-11-17 17:22 ` ebotcazou at gcc dot gnu.org
2011-11-17 17:34 ` ebotcazou at gcc dot gnu.org

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).