fold-const.c (extract_muldiv_1): If ctype is unsigned and type signed...
* fold-const.c (extract_muldiv_1) <case ABS_EXPR>: If ctype is unsigned and type signed, build ABS_EXPR with signed_type (ctype) and only afterwards convert to ctype. * gcc.c-torture/execute/20041126-1.c: New test. From-SVN: r91373
This commit is contained in:
parent
87980da05e
commit
47d42ce271
4 changed files with 51 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-11-27 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* fold-const.c (extract_muldiv_1) <case ABS_EXPR>: If ctype is
|
||||||
|
unsigned and type signed, build ABS_EXPR with signed_type (ctype)
|
||||||
|
and only afterwards convert to ctype.
|
||||||
|
|
||||||
2004-11-27 Richard Sandiford <rsandifo@redhat.com>
|
2004-11-27 Richard Sandiford <rsandifo@redhat.com>
|
||||||
|
|
||||||
* config/mips/mips-protos.h (function_arg_boundary): Declare.
|
* config/mips/mips-protos.h (function_arg_boundary): Declare.
|
||||||
|
|
|
@ -5127,7 +5127,21 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type)
|
||||||
return t1;
|
return t1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NEGATE_EXPR: case ABS_EXPR:
|
case ABS_EXPR:
|
||||||
|
/* If widening the type changes it from signed to unsigned, then we
|
||||||
|
must avoid building ABS_EXPR itself as unsigned. */
|
||||||
|
if (TYPE_UNSIGNED (ctype) && !TYPE_UNSIGNED (type))
|
||||||
|
{
|
||||||
|
tree cstype = (*lang_hooks.types.signed_type) (ctype);
|
||||||
|
if ((t1 = extract_muldiv (op0, c, code, cstype)) != 0)
|
||||||
|
{
|
||||||
|
t1 = fold (build1 (tcode, cstype, fold_convert (cstype, t1)));
|
||||||
|
return fold_convert (ctype, t1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
case NEGATE_EXPR:
|
||||||
if ((t1 = extract_muldiv (op0, c, code, wide_type)) != 0)
|
if ((t1 = extract_muldiv (op0, c, code, wide_type)) != 0)
|
||||||
return fold (build1 (tcode, ctype, fold_convert (ctype, t1)));
|
return fold (build1 (tcode, ctype, fold_convert (ctype, t1)));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2004-11-27 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* gcc.c-torture/execute/20041126-1.c: New test.
|
||||||
|
|
||||||
2004-11-27 Richard Sandiford <rsandifo@redhat.com>
|
2004-11-27 Richard Sandiford <rsandifo@redhat.com>
|
||||||
|
|
||||||
* gcc.dg/mips-args-1.c: Don't expect _R3000 or _R4000 to be defined
|
* gcc.dg/mips-args-1.c: Don't expect _R3000 or _R4000 to be defined
|
||||||
|
|
26
gcc/testsuite/gcc.c-torture/execute/20041126-1.c
Normal file
26
gcc/testsuite/gcc.c-torture/execute/20041126-1.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extern int abs (int);
|
||||||
|
extern void abort (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
check (int *p)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < 5; ++i)
|
||||||
|
if (p[i])
|
||||||
|
abort ();
|
||||||
|
for (; i < 10; ++i)
|
||||||
|
if (p[i] != i + 1)
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = -5; i < 0; i++)
|
||||||
|
a[abs (i - 10) - 11] = 0;
|
||||||
|
check (a);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue