From b1a6f8db645316b579bf6d42fdfadaea03e44a03 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 15 Jan 2003 13:43:35 +0100 Subject: [PATCH] re PR rtl-optimization/9258 (ICE in compensate_edge, at reg-stack.c:2589) PR f/9258 * global.c (struct allocno): Add no_stack_reg. (global_conflicts): Set no_stack_reg. (find_reg): Use it. * convert.c (convert_to_real): Fold - and abs only when profitable. * fold-const.c (fold): Fold truncates in - and abs. * gcc.c-torture/compile/20030115-1.c: New test. * gcc.dg/i386-fpcvt-1.c: New test. * gcc.dg/i386-fpcvt-2.c: New test. From-SVN: r61329 --- gcc/ChangeLog | 10 ++++++++++ gcc/convert.c | 8 +++++--- gcc/fold-const.c | 18 ++++++++++++++++++ gcc/global.c | 19 +++++++++++++++++-- gcc/testsuite/ChangeLog | 7 +++++++ .../g77.f-torture/compile/20030115-1.c | 14 ++++++++++++++ gcc/testsuite/gcc.dg/i386-fpcvt-3.c | 8 ++++++++ 7 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g77.f-torture/compile/20030115-1.c create mode 100644 gcc/testsuite/gcc.dg/i386-fpcvt-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a19e12ad62..87254806923 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +Wed Jan 15 12:23:21 CET 2003 Jan Hubicka + + PR f/9258 + * global.c (struct allocno): Add no_stack_reg. + (global_conflicts): Set no_stack_reg. + (find_reg): Use it. + + * convert.c (convert_to_real): Fold - and abs only when profitable. + * fold-const.c (fold): Fold truncates in - and abs. + 2003-01-15 Josef Zlomek Segher Boessenkool diff --git a/gcc/convert.c b/gcc/convert.c index 26fb6766937..009675ff19f 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -229,9 +229,11 @@ convert_to_real (type, expr) /* convert (float)-x into -(float)x. This is always safe. */ case ABS_EXPR: case NEGATE_EXPR: - return build1 (TREE_CODE (expr), type, - fold (convert_to_real (type, - TREE_OPERAND (expr, 0)))); + if (TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (expr))) + return build1 (TREE_CODE (expr), type, + fold (convert_to_real (type, + TREE_OPERAND (expr, 0)))); + break; /* convert (outertype)((innertype0)a+(innertype1)b) into ((newtype)a+(newtype)b) where newtype is the widest mode from all of these. */ diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 726e84551f5..3ab360b0dd3 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5035,6 +5035,15 @@ fold (expr) } else if (TREE_CODE (arg0) == NEGATE_EXPR) return TREE_OPERAND (arg0, 0); + /* Convert -((double)float) into (double)(-float). */ + else if (TREE_CODE (arg0) == NOP_EXPR + && TREE_CODE (type) == REAL_TYPE) + { + tree targ0 = strip_float_extensions (arg0); + if (targ0 != arg0) + return convert (type, build1 (NEGATE_EXPR, TREE_TYPE (targ0), targ0)); + + } /* Convert - (a - b) to (b - a) for non-floating-point. */ else if (TREE_CODE (arg0) == MINUS_EXPR @@ -5083,6 +5092,15 @@ fold (expr) } else if (TREE_CODE (arg0) == ABS_EXPR || TREE_CODE (arg0) == NEGATE_EXPR) return build1 (ABS_EXPR, type, TREE_OPERAND (arg0, 0)); + /* Convert fabs((double)float) into (double)fabsf(float). */ + else if (TREE_CODE (arg0) == NOP_EXPR + && TREE_CODE (type) == REAL_TYPE) + { + tree targ0 = strip_float_extensions (arg0); + if (targ0 != arg0) + return convert (type, build1 (ABS_EXPR, TREE_TYPE (targ0), targ0)); + + } else { /* fabs(sqrt(x)) = sqrt(x) and fabs(exp(x)) = exp(x). */ diff --git a/gcc/global.c b/gcc/global.c index 3b2334fcbf6..4fadc144462 100644 --- a/gcc/global.c +++ b/gcc/global.c @@ -132,6 +132,11 @@ struct allocno /* Set of hard registers that some later allocno has a preference for. */ HARD_REG_SET regs_someone_prefers; + +#ifdef STACK_REGS + /* Set to true if allocno can't be allocated in the stack register. */ + bool no_stack_reg; +#endif }; static struct allocno *allocno; @@ -708,8 +713,14 @@ global_conflicts () if (e->flags & EDGE_ABNORMAL) break; if (e != NULL) - for (ax = FIRST_STACK_REG; ax <= LAST_STACK_REG; ax++) - record_one_conflict (ax); + { + EXECUTE_IF_SET_IN_ALLOCNO_SET (allocnos_live, ax, + { + allocno[ax].no_stack_reg = 1; + }); + for (ax = FIRST_STACK_REG; ax <= LAST_STACK_REG; ax++) + record_one_conflict (ax); + } } #endif } @@ -1205,6 +1216,10 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying) #ifdef CANNOT_CHANGE_MODE_CLASS && ! invalid_mode_change_p (regno, REGNO_REG_CLASS (regno), mode) +#endif +#ifdef STACK_REGS + && (!allocno[num].no_stack_reg + || regno < FIRST_STACK_REG || regno > LAST_STACK_REG) #endif ) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c62c93115c4..0133eb2006c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +Wed Jan 15 12:20:52 CET 2003 Jan Hubicka + + * gcc.c-torture/compile/20030115-1.c: New test. + + * gcc.dg/i386-fpcvt-1.c: New test. + * gcc.dg/i386-fpcvt-2.c: New test. + 2003-01-14 Jeffrey D. Oldham Further conform g++'s __vmi_class_type_info to the C++ ABI diff --git a/gcc/testsuite/g77.f-torture/compile/20030115-1.c b/gcc/testsuite/g77.f-torture/compile/20030115-1.c new file mode 100644 index 00000000000..ec6f79c718e --- /dev/null +++ b/gcc/testsuite/g77.f-torture/compile/20030115-1.c @@ -0,0 +1,14 @@ + SUBROUTINE FOO (B) + + 10 CALL BAR(A) + ASSIGN 20 TO M + IF(100.LT.A) GOTO 10 + GOTO 40 +C + 20 IF(B.LT.ABS(A)) GOTO 10 + ASSIGN 30 TO M + GOTO 40 +C + 30 ASSIGN 10 TO M + 40 GOTO M,(10,20,30) + END diff --git a/gcc/testsuite/gcc.dg/i386-fpcvt-3.c b/gcc/testsuite/gcc.dg/i386-fpcvt-3.c new file mode 100644 index 00000000000..9a7733363ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-fpcvt-3.c @@ -0,0 +1,8 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-O2 -msse2 -march=athlon" } */ +/* { dg-final { scan-assembler-not "cvtss2sd" } } */ +float a,b; +main() +{ + a=fabs(b)+1.0; +}