public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/27006]  New: Invalid altivec constant loading code
@ 2006-04-03 18:52 uweigand at gcc dot gnu dot org
  2006-04-03 19:10 ` [Bug target/27006] [4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-03 18:52 UTC (permalink / raw)
  To: gcc-bugs

When compiling the following code with -O0 -maltivec:

typedef union
{
  int i[4];
  __attribute__((altivec(vector__))) int v;
} vec_int4;

int main (void)
{
   vec_int4 i1;

   i1.v = (__attribute__((altivec(vector__))) int){31, 31, 31, 31};
   printf ("%d\n", i1.i[0]);

   return 0;
}

the output printed is 30, not 31.

The load of the vector constant is done by the following pair
of instructions:

        vspltisw 0,15
        vadduwm 0,0,0

which are generated by this splitter in altivec.md:

(define_split
  [(set (match_operand:VI 0 "altivec_register_operand" "")
        (match_operand:VI 1 "easy_vector_constant_add_self" ""))]
  "TARGET_ALTIVEC && reload_completed"
  [(set (match_dup 0) (match_dup 3))
   (set (match_dup 0) (plus:VI (match_dup 0)
                               (match_dup 0)))]
{
  rtx dup = gen_easy_altivec_constant (operands[1]);
  rtx const_vec;

  /* Divide the operand of the resulting VEC_DUPLICATE, and use
     simplify_rtx to make a CONST_VECTOR.  */
  XEXP (dup, 0) = simplify_const_binary_operation (ASHIFTRT, QImode,
                                                   XEXP (dup, 0), const1_rtx);
  const_vec = simplify_rtx (dup);

  if (GET_MODE (const_vec) == <MODE>mode)
    operands[3] = const_vec;
  else
    operands[3] = gen_lowpart (<MODE>mode, const_vec);
})

Now, easy_vector_constand_add_self accepts all constants between
16 and 31, where I think it should really only be accepting *even*
constants.

The test is really implemented in rs6000.h:

#define EASY_VECTOR_15_ADD_SELF(n) (!EASY_VECTOR_15((n))        \
                                    && EASY_VECTOR_15((n) >> 1))

and adding a condition ((n) & 1) == 0 here fixes the problem.

Is this the proper solution?


-- 
           Summary: Invalid altivec constant loading code
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: uweigand at gcc dot gnu dot org
GCC target triplet: powerpc-*-linux*


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
@ 2006-04-03 19:10 ` pinskia at gcc dot gnu dot org
  2006-04-03 19:17 ` pinskia at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-03 19:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-04-03 19:10 -------
This worked in 4.0.2, by just loading the constant via memory so this is a
regression.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at gcc dot gnu dot org
      Known to work|                            |4.0.2
            Summary|Invalid altivec constant    |[4.1/4.2 Regression] Invalid
                   |loading code                |altivec constant loading
                   |                            |code
   Target Milestone|---                         |4.1.1


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
  2006-04-03 19:10 ` [Bug target/27006] [4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
@ 2006-04-03 19:17 ` pinskia at gcc dot gnu dot org
  2006-04-06 10:56 ` bonzini at gnu dot org
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-03 19:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-04-03 19:17 -------
Confirmed, this is definitely wrong but we can do better than disabling this
for odd vectors I think.  Adding 1 to them should work.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-04-03 19:17:18
               date|                            |


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
  2006-04-03 19:10 ` [Bug target/27006] [4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
  2006-04-03 19:17 ` pinskia at gcc dot gnu dot org
@ 2006-04-06 10:56 ` bonzini at gnu dot org
  2006-04-06 14:03 ` uweigand at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bonzini at gnu dot org @ 2006-04-06 10:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bonzini at gnu dot org  2006-04-06 10:56 -------
For 4.1 I'd surely go with Ulrich's patch.  And for 4.2 I think that it starts
being too expensive to have two vsplat and two adds.

        vspltisw 0,15
        vspltisw 1,1
        vadduwm 0,0,0
        vadduwm 0,0,1

Ulrich, can you prepare a patch or should I do so?


-- 


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-04-06 10:56 ` bonzini at gnu dot org
@ 2006-04-06 14:03 ` uweigand at gcc dot gnu dot org
  2006-04-06 14:47 ` bonzini at gnu dot org
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-06 14:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from uweigand at gcc dot gnu dot org  2006-04-06 14:03 -------
(In reply to comment #3)
> Ulrich, can you prepare a patch or should I do so?

It would be great if you could do that, I don't yet
have a proper setup for ppc testing ...


-- 


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-04-06 14:03 ` uweigand at gcc dot gnu dot org
@ 2006-04-06 14:47 ` bonzini at gnu dot org
  2006-04-13 11:47 ` uweigand at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: bonzini at gnu dot org @ 2006-04-06 14:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bonzini at gnu dot org  2006-04-06 14:47 -------
Created an attachment (id=11217)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11217&action=view)
patch to fix the bug

Patch untested but quite trivial.


-- 

bonzini at gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |bonzini at gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-04-06 14:47 ` bonzini at gnu dot org
@ 2006-04-13 11:47 ` uweigand at gcc dot gnu dot org
  2006-04-13 15:37 ` dje at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-13 11:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from uweigand at gcc dot gnu dot org  2006-04-13 11:47 -------
I've now tested and submitted the patch, thanks.


-- 

uweigand at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-
                   |                            |patches/2006-
                   |                            |04/msg00490.html
           Keywords|                            |patch


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-04-13 11:47 ` uweigand at gcc dot gnu dot org
@ 2006-04-13 15:37 ` dje at gcc dot gnu dot org
  2006-04-13 20:27 ` uweigand at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: dje at gcc dot gnu dot org @ 2006-04-13 15:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dje at gcc dot gnu dot org  2006-04-13 15:37 -------
Paolo, I'm not sure why you think that two splats and two adds is too
expensive.  Memory is moving farther and farther away from the processor.


-- 

dje at gcc dot gnu dot org changed:

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


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-04-13 15:37 ` dje at gcc dot gnu dot org
@ 2006-04-13 20:27 ` uweigand at gcc dot gnu dot org
  2006-04-13 20:34 ` uweigand at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-13 20:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from uweigand at gcc dot gnu dot org  2006-04-13 20:27 -------
Subject: Bug 27006

Author: uweigand
Date: Thu Apr 13 20:26:59 2006
New Revision: 112923

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112923
Log:
2006-04-13  Paolo Bonzini  <bonzini@gnu.org>
            Ulrich Weigand  <uweigand@de.ibm.com>

        PR target/27006
        * config/rs6000/rs6000.h (EASY_VECTOR_15_ADD_SELF): Require n
        to be even.

        PR target/27006
        * gcc.dg/vmx/pr27006.c: New testcase.


Added:
    trunk/gcc/testsuite/gcc.dg/vmx/pr27006.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/rs6000/rs6000.h
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2006-04-13 20:27 ` uweigand at gcc dot gnu dot org
@ 2006-04-13 20:34 ` uweigand at gcc dot gnu dot org
  2006-04-13 20:35 ` uweigand at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-13 20:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from uweigand at gcc dot gnu dot org  2006-04-13 20:33 -------
Subject: Bug 27006

Author: uweigand
Date: Thu Apr 13 20:33:51 2006
New Revision: 112924

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=112924
Log:
2006-04-13  Paolo Bonzini  <bonzini@gnu.org>
            Ulrich Weigand  <uweigand@de.ibm.com>

        PR target/27006
        * config/rs6000/rs6000.h (EASY_VECTOR_15_ADD_SELF): Require n
        to be even.

        PR target/27006
        * gcc.dg/vmx/pr27006.c: New testcase.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/vmx/pr27006.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/rs6000/rs6000.h
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2006-04-13 20:34 ` uweigand at gcc dot gnu dot org
@ 2006-04-13 20:35 ` uweigand at gcc dot gnu dot org
  2006-04-14  7:27 ` paolo dot bonzini at lu dot unisi dot ch
  2006-04-14 14:32 ` dje at watson dot ibm dot com
  11 siblings, 0 replies; 13+ messages in thread
From: uweigand at gcc dot gnu dot org @ 2006-04-13 20:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from uweigand at gcc dot gnu dot org  2006-04-13 20:35 -------
Fixed for 4.1 and mainline.


-- 

uweigand at gcc dot gnu dot org changed:

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


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2006-04-13 20:35 ` uweigand at gcc dot gnu dot org
@ 2006-04-14  7:27 ` paolo dot bonzini at lu dot unisi dot ch
  2006-04-14 14:32 ` dje at watson dot ibm dot com
  11 siblings, 0 replies; 13+ messages in thread
From: paolo dot bonzini at lu dot unisi dot ch @ 2006-04-14  7:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from paolo dot bonzini at lu dot unisi dot ch  2006-04-14 07:27 -------
Subject: Re:  [4.1/4.2 Regression] Invalid altivec constant
 loading code


> I'm not sure why you think that two splats and two adds is too
> expensive.
>   
I'd hope that these constants stay in the cache...

I'd be more interested in implementing a splat+shift combination to make 
EASY_VECTOR_15_ADD_SELF more generic.


-- 


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


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

* [Bug target/27006] [4.1/4.2 Regression] Invalid altivec constant loading code
  2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2006-04-14  7:27 ` paolo dot bonzini at lu dot unisi dot ch
@ 2006-04-14 14:32 ` dje at watson dot ibm dot com
  11 siblings, 0 replies; 13+ messages in thread
From: dje at watson dot ibm dot com @ 2006-04-14 14:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from dje at watson dot ibm dot com  2006-04-14 14:32 -------
Subject: Re:  [4.1/4.2 Regression] Invalid altivec constant loading code 

        One can produce a few more values fairly easily, but having GCC
know the optimal sequence for all constants could be rather bulky.

http://www.informatik.uni-bremen.de/~hobold/av/AltiVecConstants.asc
http://www.informatik.uni-bremen.de/~hobold/AltiVec.html


-- 


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


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

end of thread, other threads:[~2006-04-14 14:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-03 18:52 [Bug target/27006] New: Invalid altivec constant loading code uweigand at gcc dot gnu dot org
2006-04-03 19:10 ` [Bug target/27006] [4.1/4.2 Regression] " pinskia at gcc dot gnu dot org
2006-04-03 19:17 ` pinskia at gcc dot gnu dot org
2006-04-06 10:56 ` bonzini at gnu dot org
2006-04-06 14:03 ` uweigand at gcc dot gnu dot org
2006-04-06 14:47 ` bonzini at gnu dot org
2006-04-13 11:47 ` uweigand at gcc dot gnu dot org
2006-04-13 15:37 ` dje at gcc dot gnu dot org
2006-04-13 20:27 ` uweigand at gcc dot gnu dot org
2006-04-13 20:34 ` uweigand at gcc dot gnu dot org
2006-04-13 20:35 ` uweigand at gcc dot gnu dot org
2006-04-14  7:27 ` paolo dot bonzini at lu dot unisi dot ch
2006-04-14 14:32 ` dje at watson dot ibm dot com

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