diff options
author | Kazu Hirata <kazu@codesourcery.com> | 2005-12-26 23:00:18 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2005-12-26 23:00:18 +0000 |
commit | 4a2ab19287e25d3c883e3b0e5825317159fc752a (patch) | |
tree | 71fa7e22af360fe7beb5c11eb309505bf13890ab /gcc | |
parent | 01a097e8ec830c49674e24862d16e101c43c8932 (diff) | |
download | gcc-4a2ab19287e25d3c883e3b0e5825317159fc752a.zip gcc-4a2ab19287e25d3c883e3b0e5825317159fc752a.tar.gz gcc-4a2ab19287e25d3c883e3b0e5825317159fc752a.tar.bz2 |
re PR middle-end/25125 ((short) ((int)(unsigned short) + (int)) is done in the wrong type)
gcc/
PR tree-optimization/25125
* convert.c (convert_to_integer): Don't narrow the type of a
PLUX_EXPR or MINUS_EXPR if !flag_wrapv and the unwidened type
is signed.
gcc/testsuite/
PR tree-optimization/25125
* gcc.dg/vect/vect-7.c, gcc.dg/vect/vect-reduc-2char.c,
gcc.dg/vect/vect-reduc-2short.c: XFAIL.
* gcc.c-torture/execute/pr25125.c: New.
From-SVN: r109065
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/convert.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr25125.c | 27 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-7.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c | 2 |
7 files changed, 55 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71807d7..4695cc7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-12-26 Kazu Hirata <kazu@codesourcery.com> + + PR tree-optimization/25125 + * convert.c (convert_to_integer): Don't narrow the type of a + PLUX_EXPR or MINUS_EXPR if !flag_wrapv and the unwidened type + is signed. + 2005-12-26 Graham Stott <graham.stott@btinternet.com> PR middle-end/25568 diff --git a/gcc/convert.c b/gcc/convert.c index e8030bf..805c6f5 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -628,7 +628,17 @@ convert_to_integer (tree type, tree expr) || ex_form == RSHIFT_EXPR || ex_form == LROTATE_EXPR || ex_form == RROTATE_EXPR)) - || ex_form == LSHIFT_EXPR) + || ex_form == LSHIFT_EXPR + /* If we have !flag_wrapv, and either ARG0 or + ARG1 is of a signed type, we have to do + PLUS_EXPR or MINUS_EXPR in an unsigned + type. Otherwise, we would introduce + signed-overflow undefinedness. */ + || (!flag_wrapv + && (ex_form == PLUS_EXPR + || ex_form == MINUS_EXPR) + && (!TYPE_UNSIGNED (TREE_TYPE (arg0)) + || !TYPE_UNSIGNED (TREE_TYPE (arg1))))) typex = lang_hooks.types.unsigned_type (typex); else typex = lang_hooks.types.signed_type (typex); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2d786b5..6a44218 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2005-12-26 Kazu Hirata <kazu@codesourcery.com> + + PR tree-optimization/25125 + * gcc.dg/vect/vect-7.c, gcc.dg/vect/vect-reduc-2char.c, + gcc.dg/vect/vect-reduc-2short.c: XFAIL. + * gcc.c-torture/execute/pr25125.c: New. + 2005-12-24 Paul Thomas <pault@gcc.gnu.org> PR fortran/25029 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr25125.c b/gcc/testsuite/gcc.c-torture/execute/pr25125.c new file mode 100644 index 0000000..f08ebe7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr25125.c @@ -0,0 +1,27 @@ +extern void exit (int); +extern void abort (void); +extern unsigned short f (short a) __attribute__((__noinline__)); + +unsigned short +f (short a) +{ + short b; + + if (a > 0) + return 0; + b = ((int) a) + - (int) 32768; + return b; +} + +int +main (void) +{ + if (sizeof (short) < 2 + || sizeof (short) >= sizeof (int)) + exit (0); + + if (f (-32767) != 1) + abort (); + + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-7.c b/gcc/testsuite/gcc.dg/vect/vect-7.c index e359bbe..10cff36 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-7.c +++ b/gcc/testsuite/gcc.dg/vect/vect-7.c @@ -46,6 +46,6 @@ int main (void) } /* Fails for 32-bit targets that don't vectorize PLUS. */ -/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" { xfail *-*-* } } } */ /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c index aecf8a5..e664fda 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c @@ -45,5 +45,5 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c index 4476c83..9f312fb 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c @@ -44,5 +44,5 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail vect_no_int_max } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ |