public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/30904]  New: [dataflow] No longer optimizes shifts with large count
@ 2007-02-21  9:54 rguenth at gcc dot gnu dot org
  2007-02-21 13:31 ` [Bug middle-end/30904] " belyshev at depni dot sinp dot msu dot ru
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-21  9:54 UTC (permalink / raw)
  To: gcc-bugs

extern void link_error (const char *);
extern int ones;
void foo(int);
void kernel ()
{
    struct { unsigned int a : 7; } s;

      s.a = ones;

      if (s.a >> 8)
          link_error ("foo");
      if (s.a >> 9)
          link_error ("foo");
}

mainline optimizes this to an empty function with -O2, dataflow branch
retains the s.a >> 9 check.


-- 
           Summary: [dataflow] No longer optimizes shifts with large count
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rguenth at gcc dot gnu dot org


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
@ 2007-02-21 13:31 ` belyshev at depni dot sinp dot msu dot ru
  2007-02-21 15:58 ` steven at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: belyshev at depni dot sinp dot msu dot ru @ 2007-02-21 13:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from belyshev at depni dot sinp dot msu dot ru  2007-02-21 13:30 -------
Confirmed, same problem on alphaev56-unknown-linux-gnu.


-- 

belyshev at depni dot sinp dot msu dot ru changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
 GCC target triplet|x86_64-*-*                  |
   Last reconfirmed|0000-00-00 00:00:00         |2007-02-21 13:30:59
               date|                            |


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
  2007-02-21 13:31 ` [Bug middle-end/30904] " belyshev at depni dot sinp dot msu dot ru
@ 2007-02-21 15:58 ` steven at gcc dot gnu dot org
  2007-02-21 16:03 ` bonzini at gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: steven at gcc dot gnu dot org @ 2007-02-21 15:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from steven at gcc dot gnu dot org  2007-02-21 15:58 -------
Problem here is combine.


-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bonzini at gnu dot org
   Last reconfirmed|2007-02-21 13:30:59         |2007-02-21 15:58:48
               date|                            |


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
  2007-02-21 13:31 ` [Bug middle-end/30904] " belyshev at depni dot sinp dot msu dot ru
  2007-02-21 15:58 ` steven at gcc dot gnu dot org
@ 2007-02-21 16:03 ` bonzini at gnu dot org
  2007-02-21 16:05 ` bonzini at gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gnu dot org @ 2007-02-21 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bonzini at gnu dot org  2007-02-21 16:03 -------
This unrelated patch fixes a very similar case for powerpc

unpatched:
<       or r0,r3,r28
<       rlwinm r0,r0,0,0xff
<       cmpwi cr7,r0,0
<       beq- cr7,L4929

patched: (r3 and r28 are both extended from QImode)
>       or. r0,r3,r28
>       beq- cr0,L4929


With some luck, it does the same for this testcase too?  It would be nice to
examine why though. :-)

Sorry for the lack of professionality exhibited in this comment...

Index: combine.c
===================================================================
--- combine.c   (revision 122195)
+++ combine.c   (working copy)
@@ -1016,6 +1016,7 @@ combine_instructions (rtx f, unsigned in
 #endif
   rtx links, nextlinks;
   rtx first;
+  basic_block prev_basic_block;

   int new_direct_jump_p = 0;

@@ -1057,15 +1058,20 @@ combine_instructions (rtx f, unsigned in
      for what bits are known to be set.  */

   label_tick = label_tick_ebb_start = 1;
+  prev_basic_block = NULL;

   setup_incoming_promotions (first);
-
   create_log_links ();
+
   FOR_EACH_BB (this_basic_block)
     {
       last_call_luid = 0;
       mem_last_set = -1;
       label_tick++;
+      if (!single_pred_p (this_basic_block)
+         || single_pred (this_basic_block) != prev_basic_block)
+       label_tick_ebb_start = label_tick;
+
       FOR_BB_INSNS (this_basic_block, insn)
         if (INSN_P (insn) && BLOCK_FOR_INSN (insn))
          {
@@ -1090,8 +1096,8 @@ combine_instructions (rtx f, unsigned in
              fprintf(dump_file, "insn_cost %d: %d\n",
                    INSN_UID (insn), INSN_COST (insn));
          }
-       else if (LABEL_P (insn))
-         label_tick_ebb_start = label_tick;
+
+      prev_basic_block = this_basic_block;
     }

   nonzero_sign_valid = 1;
@@ -1099,6 +1105,8 @@ combine_instructions (rtx f, unsigned in
   /* Now scan all the insns in forward order.  */

   label_tick = label_tick_ebb_start = 1;
+  prev_basic_block = NULL;
+
   init_reg_last ();
   setup_incoming_promotions (first);

@@ -1107,6 +1115,10 @@ combine_instructions (rtx f, unsigned in
       last_call_luid = 0;
       mem_last_set = -1;
       label_tick++;
+      if (!single_pred_p (this_basic_block)
+          || single_pred (this_basic_block) != prev_basic_block)
+        label_tick_ebb_start = label_tick;
+     
       for (insn = BB_HEAD (this_basic_block);
           insn != NEXT_INSN (BB_END (this_basic_block));
           insn = next ? next : NEXT_INSN (insn))
@@ -1253,9 +1265,9 @@ combine_instructions (rtx f, unsigned in
            retry:
              ;
            }
-         else if (LABEL_P (insn))
-           label_tick_ebb_start = label_tick;
        }
+
+      prev_basic_block = this_basic_block;
     }

   clear_log_links ();


-- 


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-02-21 16:03 ` bonzini at gnu dot org
@ 2007-02-21 16:05 ` bonzini at gnu dot org
  2007-02-21 16:11 ` bonzini at gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gnu dot org @ 2007-02-21 16:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from bonzini at gnu dot org  2007-02-21 16:05 -------
It doesn't, but I confirm that the bug is target independent.  A way to fix it
would be to do the transform in VRP, but I'll look at combine if time permits.


-- 


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-02-21 16:05 ` bonzini at gnu dot org
@ 2007-02-21 16:11 ` bonzini at gnu dot org
  2007-02-21 16:24 ` bonzini at gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gnu dot org @ 2007-02-21 16:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bonzini at gnu dot org  2007-02-21 16:11 -------
The first one is in the same EBB as the assignment.  The second one isn't and
combine screws up.  This is because of the way combine treats regs with one def
that dominates all uses, I talked to zadeck yesterday about that on IRC.


-- 


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


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

* [Bug middle-end/30904] [dataflow] No longer optimizes shifts with large count
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-02-21 16:11 ` bonzini at gnu dot org
@ 2007-02-21 16:24 ` bonzini at gnu dot org
  2007-02-22  8:41 ` [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields? bonzini at gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gnu dot org @ 2007-02-21 16:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from bonzini at gnu dot org  2007-02-21 16:23 -------
Created an attachment (id=13083)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13083&action=view)
patch to fix the bug

The logic in trunk's combine with respect to uninitialized variables is
correct.

We have to look at DF_LR_IN for the entry basic block to find variables that
are not used uninitialized.

In fact, the name of DF_UR_IN is misleading, as it computes *initialized*
registers.


-- 


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


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

* [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields?
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-02-21 16:24 ` bonzini at gnu dot org
@ 2007-02-22  8:41 ` bonzini at gnu dot org
  2007-02-24 16:08 ` bonzini at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gnu dot org @ 2007-02-22  8:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from bonzini at gnu dot org  2007-02-22 08:41 -------
Now that the patch has been applied to dataflow branch, this remains as a
missed optimization on the tree level.


-- 

bonzini at gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|spark at gcc dot gnu dot org|
          Component|middle-end                  |tree-optimization
           Keywords|                            |TREE
            Summary|[dataflow] No longer        |VRP does not track values of
                   |optimizes shifts with large |shifts and/or bitfields?
                   |count                       |


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


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

* [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields?
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-02-22  8:41 ` [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields? bonzini at gnu dot org
@ 2007-02-24 16:08 ` bonzini at gcc dot gnu dot org
  2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
  2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: bonzini at gcc dot gnu dot org @ 2007-02-24 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from bonzini at gnu dot org  2007-02-24 16:07 -------
Subject: Bug 30904

Author: bonzini
Date: Sat Feb 24 16:07:41 2007
New Revision: 122290

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122290
Log:
2007-02-23  Paolo Bonzini  <bonzini@gnu.org>

        PR tree-optimization/30904
        * gcc.dg/pr30904.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr30904.c
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields?
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-02-24 16:08 ` bonzini at gcc dot gnu dot org
@ 2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
  2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-09 12:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2007-03-09 12:29 -------
Subject: Bug 30904

Author: rguenth
Date: Fri Mar  9 12:29:09 2007
New Revision: 122748

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122748
Log:
2007-03-09  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/30904
        PR middle-end/31058
        * tree-vrp.c (extract_range_from_binary_expr): Handle RSHIFT_EXPR
        the same way as *_DIV_EXPR.

        * gcc.dg/pr30904.c: Remove xfail.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/pr30904.c
    trunk/gcc/tree-vrp.c


-- 


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


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

* [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields?
  2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
@ 2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-03-09 12:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2007-03-09 12:29 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-03-09 12:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-21  9:54 [Bug middle-end/30904] New: [dataflow] No longer optimizes shifts with large count rguenth at gcc dot gnu dot org
2007-02-21 13:31 ` [Bug middle-end/30904] " belyshev at depni dot sinp dot msu dot ru
2007-02-21 15:58 ` steven at gcc dot gnu dot org
2007-02-21 16:03 ` bonzini at gnu dot org
2007-02-21 16:05 ` bonzini at gnu dot org
2007-02-21 16:11 ` bonzini at gnu dot org
2007-02-21 16:24 ` bonzini at gnu dot org
2007-02-22  8:41 ` [Bug tree-optimization/30904] VRP does not track values of shifts and/or bitfields? bonzini at gnu dot org
2007-02-24 16:08 ` bonzini at gcc dot gnu dot org
2007-03-09 12:29 ` rguenth at gcc dot gnu dot org
2007-03-09 12:29 ` rguenth at gcc dot gnu dot 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).