Commit 4a2ab192 by Kazu Hirata Committed by Kazu Hirata

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
parent 01a097e8
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
......
......@@ -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);
......
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
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);
}
......@@ -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" } } */
......@@ -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" } } */
......@@ -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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment