public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [TESTCASE] Minimized testcase for AltiVec segfault
@ 2002-02-26  5:17 Daniel Egger
  2002-02-26  8:38 ` David Edelsohn
  2002-02-26 21:38 ` Aldy Hernandez
  0 siblings, 2 replies; 44+ messages in thread
From: Daniel Egger @ 2002-02-26  5:17 UTC (permalink / raw)
  To: GCC Developer Mailinglist; +Cc: Aldy Hernandez

[-- Attachment #1: Type: text/plain, Size: 1684 bytes --]

Hija,

the attached testcase will segfault on powerpc-linux when compiled with
-O0.

egger@sonja:~$ /opt/gcc/bin/gcc -da -maltivec -save-temps -O0 -mregnames
test2.c -o test2 -Wall
test2.c: In function `do_something':
test2.c:7: warning: unused variable `zeros'
egger@sonja:~$ ./test2 
Segmentation fault

Works with -O2:
egger@sonja:~$ /opt/gcc/bin/gcc -da -maltivec -save-temps -O2 -mregnames
test2.c -o test2 -Wall
test2.c: In function `do_something':
test2.c:7: warning: unused variable `zeros'
egger@sonja:~$ ./test2 
egger@sonja:~$ 

do_something:
        stwu %r1,-96(%r1)
        stw %r31,92(%r1)
        mr %r31,%r1
        stw %r3,8(%r31)
        lis %r9,.LC0@ha
        la %r9,.LC0@l(%r9)
        lvx %v0,0,%r9
        li %r0,32
        stvx %v0,%r31,%r0
        li %r0,32
        lvx %v0,%r31,%r0
        li %r0,16
        stvx %v0,%r31,%r0
        lwz %r0,8(%r31)
        stw %r0,48(%r31)
        lwz %r9,48(%r31)
        lvx %v0,0,%r9       <--- This is an offending line.
        li %r0,56
        stvx %v0,%r31,%r0
        lwz %r9,48(%r31)
        li %r0,56
        lvx %v0,%r31,%r0
        stvx %v0,0,%r9      <--- This is an offending line.
        lwz %r11,0(%r1)
        lwz %r31,-4(%r11)
        mr %r1,%r11
        blr

One problem with this marked lines is that there is no direct vector
load or vector store with the second argument being 0 to directly
address the memory at the pointer in the third argument which gcc seem
to assume exists.

Even worse for the store is that %r9 points to 0 and %r0 is 56 (while
it is probably assumed to be ignored) which means that address
generation is wrong anyway even if the syntax was right.

-- 
Servus,
       Daniel

[-- Attachment #2: Type: text/x-c, Size: 453 bytes --]

#include <altivec.h>
#include <malloc.h>

void
do_something (signed short *mem)
{
  const vector signed short zeros = (vector signed short) {0,0,0,0,0,0,0};
  vector signed short *vec;
  vector signed short v1[1];

  vec = (vector signed short *) mem;
  
  v1[0] = vec[0];
  vec[0] = v1[0];
}

int
main (void)
{
  void *mem = memalign (128, 16);
  
  if (mem)
  {
    do_something (mem);
    free (mem);
  }
 
  return 0;
}

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [TESTCASE] Minimized testcase for AltiVec segfault
@ 2002-02-27 18:02 Robert Dewar
  0 siblings, 0 replies; 44+ messages in thread
From: Robert Dewar @ 2002-02-27 18:02 UTC (permalink / raw)
  To: geoffk, rth; +Cc: gcc

<<If -mpowerpc produces "incorrect" code, you get told that you
don't know what you're doing.  So why have options with such
tantilizing names?
>>

i see nothing tantalizing about the name, this seems a weak and
unconvincing argument.

^ permalink raw reply	[flat|nested] 44+ messages in thread
* Re: [TESTCASE] Minimized testcase for AltiVec segfault
@ 2002-02-28 11:40 mike stump
  0 siblings, 0 replies; 44+ messages in thread
From: mike stump @ 2002-02-28 11:40 UTC (permalink / raw)
  To: geoffk, mark, rth; +Cc: gcc

> Date: Wed, 27 Feb 2002 22:58:57 -0800
> From: Mark Mitchell <mark@codesourcery.com>
> To: Geoff Keating <geoffk@geoffk.org>, Richard Henderson <rth@redhat.com>
> cc: "gcc@gcc.gnu.org" <gcc@gcc.gnu.org>

> > David's comment applies to every option that GCC has; there's no need
> > to go around renaming -funroll-all-loops to -fdebug-unroll-all-loops
> > just because it's sometimes ineffective or dangerous.

> But if I had my way that option, and many other optimization knobs,
> would not exist at all in released versions of GCC!

It would be great if someone fixed all the important outstanding
deficiencies with -funroll-all-loops and made it the default and
removed the option.  :-)

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

end of thread, other threads:[~2002-03-01  1:58 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-26  5:17 [TESTCASE] Minimized testcase for AltiVec segfault Daniel Egger
2002-02-26  8:38 ` David Edelsohn
2002-02-26 10:14   ` Daniel Egger
2002-02-26 21:38 ` Aldy Hernandez
2002-02-27 15:06   ` Daniel Egger
2002-02-27 15:19     ` Aldy Hernandez
2002-02-27 15:37       ` Daniel Egger
2002-02-27 15:39         ` Aldy Hernandez
2002-02-27 16:08           ` Kumar Gala
2002-02-27 17:28             ` Alex Rosenberg
2002-02-27 18:14               ` Daniel Egger
2002-02-27 18:46                 ` Alex Rosenberg
2002-02-27 22:59                   ` Aldy Hernandez
2002-02-28 14:25                     ` Alex Rosenberg
2002-02-28 15:01                       ` Aldy Hernandez
2002-02-27 18:20             ` Aldy Hernandez
2002-02-27 18:30               ` Geoff Keating
2002-02-27 18:32                 ` Aldy Hernandez
2002-02-27 19:22                   ` Geoff Keating
2002-02-27 21:46                     ` Aldy Hernandez
2002-02-28  8:26                       ` Geoff Keating
2002-02-28 14:29                         ` Aldy Hernandez
2002-02-28 20:21                           ` Geoff Keating
2002-02-28 20:28                             ` Aldy Hernandez
2002-02-28 14:09                       ` Alex Rosenberg
2002-02-27 19:35               ` Kumar Gala
2002-02-27 19:54                 ` Dale Johannesen
2002-02-27 22:07                   ` Aldy Hernandez
2002-02-28 14:47                     ` Dale Johannesen
2002-02-27 17:43           ` Geoff Keating
2002-02-27 18:30             ` Aldy Hernandez
2002-02-27 19:32               ` Geoff Keating
2002-02-27 18:12           ` Daniel Egger
2002-02-27 16:43       ` David Edelsohn
2002-02-27 17:25         ` Richard Henderson
2002-02-27 17:47           ` Geoff Keating
2002-02-27 17:51             ` Richard Henderson
2002-02-27 18:28               ` Geoff Keating
2002-02-28  0:42                 ` Richard Henderson
2002-02-28  8:48                   ` Geoff Keating
2002-02-27 23:35             ` Mark Mitchell
2002-02-27 15:09   ` Daniel Egger
2002-02-27 18:02 Robert Dewar
2002-02-28 11:40 mike stump

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