public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19857] New: alignment check of SSE constant fails in simple test program
@ 2005-02-09 21:20 gcc-bugzilla at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2005-02-09 21:20 UTC (permalink / raw)
To: gcc-bugs
When I compile a simple test program that declares an SSE constant and checks
that it is 8-byte aligned (see below), the alignment check fails in the
gcc 4.0 snapshot (it succeeds in 3.3.5).
I'm not sure whether the constant is actually misaligned or the alignment
check itself is miscompiled...changing the check slightly makes it succeed.
Environment:
System: Linux fftw.org 2.6.3-1-686-smp #2 SMP Tue Feb 24 20:29:08 EST 2004 i686 GNU/Linux
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/home/stevenj/gcc4
How-To-Repeat:
Compile the following code with 'gcc -O3 -msse -o bug bug.c' and run
with './bug && echo ok' ... output *should* be "ok" (ALIGNED==true),
but is not.
(Yes, the way the alignment check is performed looks kinda weird...it
is distilled from other code (www.fftw.org), obviously...but it should
still pass for any 8-byte aligned quantity.)
Thanks for looking into this,
Steven G. Johnson
typedef float V __attribute__ ((vector_size (16)));
union fvec {
float f[4];
V v;
};
typedef unsigned int uintptr_t;
#define ALIGNMENT 8
#define TAINT_BIT 1
#define UNTAINT(p) ((float *) (((uintptr_t) (p)) & ~(uintptr_t)3))
#define PTRINT(p) ((uintptr_t)(p))
#define ALIGNED(p) \
(((PTRINT(UNTAINT(p)) % ALIGNMENT) == 0) && !(PTRINT(p) & TAINT_BIT))
const union fvec foo = {{-0.0, 0.0, -0.0, 0.0}};
int main(void)
{
return !ALIGNED(&foo);
}
--
Summary: alignment check of SSE constant fails in simple test
program
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: critical
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stevenj at fftw dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug regression/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
@ 2005-02-10 0:29 ` pinskia at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression " pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-10 0:29 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.0 Regression alignment |[4.0 Regression] alignment
|check of SSE constant fails |check of SSE constant fails
|in simple test program |in simple test program
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug regression/19857] [4.0 Regression alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-02-10 0:29 ` pinskia at gcc dot gnu dot org
2005-02-10 0:51 ` [Bug middle-end/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-10 0:29 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |normal
Component|c |regression
Keywords| |wrong-code
Summary|alignment check of SSE |[4.0 Regression alignment
|constant fails in simple |check of SSE constant fails
|test program |in simple test program
Target Milestone|--- |4.0.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression " pinskia at gcc dot gnu dot org
@ 2005-02-10 0:51 ` pinskia at gcc dot gnu dot org
2005-02-10 20:46 ` jakub at gcc dot gnu dot org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-02-10 0:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-02-09 21:24 -------
Confirmed, here is a testcase which uses abort:
typedef float V __attribute__ ((vector_size (16)));
typedef __SIZE_TYPE__ uintptr_t;
V foo;
void abort (void);
int main(void)
{
V *foo2 = &foo;
if (!(((((uintptr_t)(((float *) (((uintptr_t) foo2) & ~(uintptr_t)3)))) % 8) == 0) && !(((uintptr_t)foo2) & 1)))
abort ();
return 0;
}
--
What |Removed |Added
----------------------------------------------------------------------------
OtherBugsDependingO| |19858
nThis| |
Status|UNCONFIRMED |NEW
Component|regression |middle-end
Ever Confirmed| |1
GCC build triplet|i686-pc-linux-gnu |
GCC host triplet|i686-pc-linux-gnu |
GCC target triplet|i686-pc-linux-gnu |
Known to fail| |4.0.0
Known to work| |3.3.2
Last reconfirmed|0000-00-00 00:00:00 |2005-02-09 21:24:32
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
` (2 preceding siblings ...)
2005-02-10 0:51 ` [Bug middle-end/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-02-10 20:46 ` jakub at gcc dot gnu dot org
2005-02-10 21:11 ` jakub at gcc dot gnu dot org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-10 20:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-10 17:21 -------
This looks like fold_truthop bug, will look at it.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |jakub at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2005-02-09 21:24:32 |2005-02-10 17:21:35
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
` (3 preceding siblings ...)
2005-02-10 20:46 ` jakub at gcc dot gnu dot org
@ 2005-02-10 21:11 ` jakub at gcc dot gnu dot org
2005-02-15 20:52 ` jakub at gcc dot gnu dot org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-10 21:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-10 18:07 -------
Actually, I see there multiple problems elsewhere.
First is on
int i;
int foo (void)
{
return i & ~(unsigned int)3;
}
First is that
if (change)
return fold (build2 (BIT_AND_EXPR, type,
fold_convert (type, and0),
fold_convert (type, and1)));
folds (int) ((unsigned)i & ~(unsigned)3) into i & (int)~(unsigned)3 where
(int)~(unsigned)3 is -4 with TREE_OVERFLOW set. But there is no overflow
in the original program, so we shouldn't IMHO create one as part of this
optimization.
Another problem is that
case POINTER_TYPE:
case REFERENCE_TYPE:
if (integer_zerop (expr))
expr = integer_zero_node;
else
expr = fold (build1 (CONVERT_EXPR,
lang_hooks.types.type_for_size (POINTER_SIZE, 0),
expr));
return convert_to_integer (type, expr);
unconditionally converts to signed type as wide as pointer (== intptr_t) instead
of considering TYPE_UNSIGNED (type).
As the result of these 2, fold_truthop is presented with ll_mask and ll_and_mask
TREE_OVERFLOW -4 and given that gets confused into believing the whole comparison
is always 0.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
` (4 preceding siblings ...)
2005-02-10 21:11 ` jakub at gcc dot gnu dot org
@ 2005-02-15 20:52 ` jakub at gcc dot gnu dot org
2005-02-16 18:06 ` cvs-commit at gcc dot gnu dot org
2005-02-16 18:13 ` jakub at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-15 20:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-15 11:42 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00810.html>
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
` (5 preceding siblings ...)
2005-02-15 20:52 ` jakub at gcc dot gnu dot org
@ 2005-02-16 18:06 ` cvs-commit at gcc dot gnu dot org
2005-02-16 18:13 ` jakub at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-02-16 18:06 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2005-02-16 13:54 -------
Subject: Bug 19857
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: jakub@gcc.gnu.org 2005-02-16 13:54:31
Modified files:
gcc : ChangeLog convert.c fold-const.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/gcc.c-torture/execute: 20050215-1.c
gcc/testsuite/gcc.dg/tree-ssa: 20050215-1.c
Log message:
PR middle-end/19857
* fold-const.c (fold): Don't optimize (T)(x & cst) to
(T)x & (T)cst if (T)cst overflows.
* convert.c (convert_to_integer) <case POINTER_TYPE>: Pass
TYPE_UNSIGNED (type) as type_for_size's UNSIGNEDP argument.
* gcc.dg/tree-ssa/20050215-1.c: New test.
* gcc.c-torture/execute/20050215-1.c: New test.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7491&r2=2.7492
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/convert.c.diff?cvsroot=gcc&r1=1.54&r2=1.55
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fold-const.c.diff?cvsroot=gcc&r1=1.512&r2=1.513
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5039&r2=1.5040
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20050215-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/tree-ssa/20050215-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug middle-end/19857] [4.0 Regression] alignment check of SSE constant fails in simple test program
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
` (6 preceding siblings ...)
2005-02-16 18:06 ` cvs-commit at gcc dot gnu dot org
@ 2005-02-16 18:13 ` jakub at gcc dot gnu dot org
7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-02-16 18:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-16 13:58 -------
Fixed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19857
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-02-16 13:58 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-09 21:20 [Bug c/19857] New: alignment check of SSE constant fails in simple test program gcc-bugzilla at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-10 0:29 ` [Bug regression/19857] [4.0 Regression " pinskia at gcc dot gnu dot org
2005-02-10 0:51 ` [Bug middle-end/19857] [4.0 Regression] " pinskia at gcc dot gnu dot org
2005-02-10 20:46 ` jakub at gcc dot gnu dot org
2005-02-10 21:11 ` jakub at gcc dot gnu dot org
2005-02-15 20:52 ` jakub at gcc dot gnu dot org
2005-02-16 18:06 ` cvs-commit at gcc dot gnu dot org
2005-02-16 18:13 ` jakub 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).