aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2003-01-15 13:43:35 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2003-01-15 12:43:35 +0000
commitb1a6f8db645316b579bf6d42fdfadaea03e44a03 (patch)
tree6deb389e7c733b4c85650e832ec219085b0ff935 /gcc
parentd18c7e595f818f688d073496d64fae9c00b594d6 (diff)
downloadgcc-b1a6f8db645316b579bf6d42fdfadaea03e44a03.zip
gcc-b1a6f8db645316b579bf6d42fdfadaea03e44a03.tar.gz
gcc-b1a6f8db645316b579bf6d42fdfadaea03e44a03.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/convert.c8
-rw-r--r--gcc/fold-const.c18
-rw-r--r--gcc/global.c19
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/g77.f-torture/compile/20030115-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/i386-fpcvt-3.c8
7 files changed, 79 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9a19e12..8725480 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+Wed Jan 15 12:23:21 CET 2003 Jan Hubicka <jh@suse.cz>
+
+ 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 <zlomekj@suse.cz>
Segher Boessenkool <segher@koffie.nl>
diff --git a/gcc/convert.c b/gcc/convert.c
index 26fb676..009675f 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 726e845..3ab360b 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 3b2334f..4fadc14 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
}
@@ -1206,6 +1217,10 @@ find_reg (num, losers, alt_regs_p, accept_call_clobbered, retrying)
&& ! 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
)
{
/* We explicitly evaluate the divide results into temporary
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c62c931..0133eb2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jan 15 12:20:52 CET 2003 Jan Hubicka <jh@suse.cz>
+
+ * 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 <oldham@codesourcery.com>
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 0000000..ec6f79c
--- /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 0000000..9a77333
--- /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;
+}