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
This commit is contained in:
Kazu Hirata 2005-12-26 23:00:18 +00:00 committed by Kazu Hirata
parent 01a097e8ec
commit 4a2ab19287
7 changed files with 55 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);
}

View File

@ -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" } } */

View File

@ -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" } } */

View File

@ -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" } } */