public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/30970]  New: Register zeroing by xor N,N should be moved out of loop
@ 2007-02-26 13:35 ubizjak at gmail dot com
  2007-02-26 15:48 ` [Bug target/30970] " ubizjak at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2007-02-26 13:35 UTC (permalink / raw)
  To: gcc-bugs

The testcase:

--cut here--
#define N 256
int b[N];

void test()
{  
  int i;

  for (i = 0; i < N; i++)
    b[i] = 0;
}
--cut here--

compiles with '-O2 -msse2 -ftree-vectorize' into:

test:
        movl    $16, %eax
        pxor    %xmm0, %xmm0
        movdqa  %xmm0, b
        .p2align 4,,7
.L2:
        pxor    %xmm0, %xmm0
        movdqa  %xmm0, b(%eax)
        addl    $16, %eax
        cmpl    $1024, %eax
        jne     .L2
        rep ; ret

Please note second pxor that is _not_ needed. Also, it should be moved out of
loop as it is loop invariant.

For slightly different testcase, where 'b[i] = 1' (or anything != 0) we get
optimized code:

test:
        movl    $16, %eax
        movdqa  .LC0, %xmm0
        movdqa  %xmm0, b
        .p2align 4,,7
.L2:
        movdqa  %xmm0, b(%eax)
        addl    $16, %eax
        cmpl    $1024, %eax
        jne     .L2
        rep ; ret

It looks like (g)cse doesn't know what 'xor N,N' means.


-- 
           Summary: Register zeroing by xor N,N should be moved out of loop
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ubizjak at gmail dot com
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
@ 2007-02-26 15:48 ` ubizjak at gmail dot com
  2007-02-26 17:35 ` rguenth at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2007-02-26 15:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ubizjak at gmail dot com  2007-02-26 15:48 -------
It is a target issue. Working on a fix.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |ubizjak at gmail dot com
                   |dot org                     |
           Severity|normal                      |minor
             Status|UNCONFIRMED                 |ASSIGNED
          Component|rtl-optimization            |target
     Ever Confirmed|0                           |1
 GCC target triplet|                            |i686-pc-linux-gnu
           Keywords|                            |ssemmx
   Last reconfirmed|0000-00-00 00:00:00         |2007-02-26 15:48:01
               date|                            |
   Target Milestone|---                         |4.3.0


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
  2007-02-26 15:48 ` [Bug target/30970] " ubizjak at gmail dot com
@ 2007-02-26 17:35 ` rguenth at gcc dot gnu dot org
  2007-02-26 17:54 ` pinskia at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-26 17:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2007-02-26 17:35 -------
Shouldn't rtl invariant motion catch this?


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rakdver at gcc dot gnu dot
                   |                            |org


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
  2007-02-26 15:48 ` [Bug target/30970] " ubizjak at gmail dot com
  2007-02-26 17:35 ` rguenth at gcc dot gnu dot org
@ 2007-02-26 17:54 ` pinskia at gcc dot gnu dot org
  2007-02-26 19:51 ` ubizjak at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-02-26 17:54 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.3.0                       |---


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
                   ` (2 preceding siblings ...)
  2007-02-26 17:54 ` pinskia at gcc dot gnu dot org
@ 2007-02-26 19:51 ` ubizjak at gmail dot com
  2007-02-27 21:27 ` uros at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2007-02-26 19:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from ubizjak at gmail dot com  2007-02-26 19:51 -------
(In reply to comment #2)
> Shouldn't rtl invariant motion catch this?

It would be nice, but the problem is again in the fact that we lie to the
compiler about supported instructions. This one is not a valid x86 insn:

(insn 12 8 13 2 (set (mem:V4SI (symbol_ref:DI ("b") <var_decl 0x2aaaae15b000
b>) [3 S16 A128])
        (const_vector:V4SI [
                (const_int 0 [0x0])
                (const_int 0 [0x0])
                (const_int 0 [0x0])
                (const_int 0 [0x0])
            ])) 919 {*movv4si_internal} (nil)
    (nil))

This sequence is later split into pxor+store, unfortunatelly a bit late in the
game, after RTL optimizers have already done their job.


-- 


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
                   ` (3 preceding siblings ...)
  2007-02-26 19:51 ` ubizjak at gmail dot com
@ 2007-02-27 21:27 ` uros at gcc dot gnu dot org
  2007-03-02 14:54 ` ubizjak at gmail dot com
  2007-03-02 18:37 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: uros at gcc dot gnu dot org @ 2007-02-27 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from uros at gcc dot gnu dot org  2007-02-27 21:27 -------
Subject: Bug 30970

Author: uros
Date: Tue Feb 27 21:27:27 2007
New Revision: 122387

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122387
Log:
        PR target/30970
        * config/i386/sse.md (*mov<mode>_internal, *movv4sf_internal,
        *movv2df_internal): Enable pattern only for valid operand
        combinations.
        * config/i386/i386.c (ix86_modes_tieable_p): For SSE registers,
        tie only 128bit modes. For MMX registers, tie only 64bit modes.

testsuite/ChangeLog:

        PR target/30970
        * gcc.target/i386/gfortran.dg/pr30970.c: New test. 


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr30970.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/sse.md
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
                   ` (4 preceding siblings ...)
  2007-02-27 21:27 ` uros at gcc dot gnu dot org
@ 2007-03-02 14:54 ` ubizjak at gmail dot com
  2007-03-02 18:37 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: ubizjak at gmail dot com @ 2007-03-02 14:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from ubizjak at gmail dot com  2007-03-02 14:54 -------
Fixed in mainline.


-- 

ubizjak at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug target/30970] Register zeroing by xor N,N should be moved out of loop
  2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
                   ` (5 preceding siblings ...)
  2007-03-02 14:54 ` ubizjak at gmail dot com
@ 2007-03-02 18:37 ` pinskia at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-02 18:37 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-03-02 18:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-26 13:35 [Bug rtl-optimization/30970] New: Register zeroing by xor N,N should be moved out of loop ubizjak at gmail dot com
2007-02-26 15:48 ` [Bug target/30970] " ubizjak at gmail dot com
2007-02-26 17:35 ` rguenth at gcc dot gnu dot org
2007-02-26 17:54 ` pinskia at gcc dot gnu dot org
2007-02-26 19:51 ` ubizjak at gmail dot com
2007-02-27 21:27 ` uros at gcc dot gnu dot org
2007-03-02 14:54 ` ubizjak at gmail dot com
2007-03-02 18:37 ` pinskia 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).