]> gcc.gnu.org Git - gcc.git/commitdiff
re PR rtl-optimization/9258 (ICE in compensate_edge, at reg-stack.c:2589)
authorJan Hubicka <jh@suse.cz>
Wed, 15 Jan 2003 12:43:35 +0000 (13:43 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 15 Jan 2003 12:43:35 +0000 (12:43 +0000)
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
gcc/convert.c
gcc/fold-const.c
gcc/global.c
gcc/testsuite/ChangeLog
gcc/testsuite/g77.f-torture/compile/20030115-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/i386-fpcvt-3.c [new file with mode: 0644]

index 9a19e12ad62b9a847b5bdc8c887a49c0916f6532..87254806923aca9d05247c31ffb59abcc491315d 100644 (file)
@@ -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>
index 26fb67669379e1bc5e0ef90dd336a4006457c9e9..009675ff19f7dfede19f298eaa26b1b75b4bccee 100644 (file)
@@ -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.  */
index 726e84551f572731b070c20b708a56f0408df62c..3ab360b0dd3a2850aedfdc59d0ef7c51eb2c4783 100644 (file)
@@ -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).  */
index 3b2334fcbf62f49a8cbcb346cc8e0750bd581588..4fadc144462ff29214f8f3418bc699d6e5cc3cf0 100644 (file)
@@ -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
              )
            {
index c62c93115c4f99d1d0d3fc4675829a4f6f618a37..0133eb2006c6579904bb2838c0cf236164e85100 100644 (file)
@@ -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 (file)
index 0000000..ec6f79c
--- /dev/null
@@ -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 (file)
index 0000000..9a77333
--- /dev/null
@@ -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;
+}
This page took 0.089944 seconds and 5 git commands to generate.