This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix old problem in if-conversion pass


> > The problem is that noce_try_abs forgets to negate the transformation
> > when the comparison (f < 0.0) is written as (0.0 > f).
>
> Can you write a test case for this problem?

Sure, attached.  Aborts if 

@@ -1718,25 +1720,30 @@ noce_try_abs (struct noce_if_info *if_in
   if (rtx_equal_p (XEXP (cond, 0), b))
     c = XEXP (cond, 1);
   else if (rtx_equal_p (XEXP (cond, 1), b))
-    c = XEXP (cond, 0);
+    {
+      c = XEXP (cond, 0);
+      negate = !negate;
+    }
   else

is removed from the patch.


2005-11-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/ifcvt-fabs-1.c: New test.


-- 
Eric Botcazou
/* { dg-do run } */
/* { dg-options "-O" } */
/* { dg-options "-O -march=i686" { target i686-*-* } } */

extern void abort(void);

float foo(float f)
{
  if (f < 0.0)
    f = -f;

  return f;
}

int main(void)
{
  if (foo(-1.0) != 1.0)
    abort ();

  return 0;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]