Blame SOURCES/gcc34-rh207277.patch

6693b3
2006-12-08  Jakub Jelinek  <jakub@redhat.com>
6693b3
6693b3
	* g++.dg/opt/ifcvt1.C: New test.
6693b3
6693b3
2005-11-09  Eric Botcazou  <ebotcazou@adacore.com>
6693b3
6693b3
	* ifcvt.c (noce_get_alt_condition): Use prev_nonnote_insn.
6693b3
	(noce_try_abs): Negate if the comparison is reversed.
6693b3
	Look only one instruction backwards for a REG_EQUAL note.
6693b3
6693b3
	* gcc.dg/ifcvt-fabs-1.c: New test.
6693b3
6693b3
--- gcc/ifcvt.c.orig	2005-11-21 11:43:21.000000000 -0200
6693b3
+++ gcc/ifcvt.c	2006-10-26 02:21:07.000000000 -0300
6693b3
@@ -1406,7 +1406,7 @@ noce_get_alt_condition (struct noce_if_i
6693b3
       rtx prev_insn;
6693b3
 
6693b3
       /* First, look to see if we put a constant in a register.  */
6693b3
-      prev_insn = PREV_INSN (if_info->cond_earliest);
6693b3
+      prev_insn = prev_nonnote_insn (if_info->cond_earliest);
6693b3
       if (prev_insn
6693b3
 	  && INSN_P (prev_insn)
6693b3
 	  && GET_CODE (PATTERN (prev_insn)) == SET)
6693b3
@@ -1642,25 +1642,30 @@ noce_try_abs (struct noce_if_info *if_in
6693b3
   if (rtx_equal_p (XEXP (cond, 0), b))
6693b3
     c = XEXP (cond, 1);
6693b3
   else if (rtx_equal_p (XEXP (cond, 1), b))
6693b3
-    c = XEXP (cond, 0);
6693b3
+    {
6693b3
+      c = XEXP (cond, 0);
6693b3
+      negate = !negate;
6693b3
+    }
6693b3
   else
6693b3
     return FALSE;
6693b3
 
6693b3
-  /* Verify that C is zero.  Search backward through the block for
6693b3
-     a REG_EQUAL note if necessary.  */
6693b3
+  /* Verify that C is zero.  Search one step backward for a
6693b3
+     REG_EQUAL note or a simple source if necessary.  */
6693b3
   if (REG_P (c))
6693b3
     {
6693b3
-      rtx insn, note = NULL;
6693b3
-      for (insn = earliest;
6693b3
-	   insn != BB_HEAD (if_info->test_bb);
6693b3
-	   insn = PREV_INSN (insn))
6693b3
-	if (INSN_P (insn)
6693b3
-	    && ((note = find_reg_note (insn, REG_EQUAL, c))
6693b3
-		|| (note = find_reg_note (insn, REG_EQUIV, c))))
6693b3
-	  break;
6693b3
-      if (! note)
6693b3
+      rtx set, insn = prev_nonnote_insn (earliest);
6693b3
+      if (insn
6693b3
+	  && (set = single_set (insn))
6693b3
+	  && rtx_equal_p (SET_DEST (set), c))
6693b3
+	{
6693b3
+	  rtx note = find_reg_equal_equiv_note (insn);
6693b3
+	  if (note)
6693b3
+	    c = XEXP (note, 0);
6693b3
+	  else
6693b3
+	    c = SET_SRC (set);
6693b3
+	}
6693b3
+      else
6693b3
 	return FALSE;
6693b3
-      c = XEXP (note, 0);
6693b3
     }
6693b3
   if (GET_CODE (c) == MEM
6693b3
       && GET_CODE (XEXP (c, 0)) == SYMBOL_REF
6693b3
--- gcc/testsuite/gcc.dg/ifcvt-fabs-1.c	1970-01-01 00:00:00.000000000 +0000
6693b3
+++ gcc/testsuite/gcc.dg/ifcvt-fabs-1.c	2006-10-26 02:20:24.000000000 -0300
6693b3
@@ -0,0 +1,21 @@
6693b3
+/* { dg-do run } */
6693b3
+/* { dg-options "-O" } */
6693b3
+/* { dg-options "-O -march=i686" { target i686-*-* } } */
6693b3
+
6693b3
+extern void abort(void);
6693b3
+
6693b3
+float foo(float f)
6693b3
+{
6693b3
+  if (f < 0.0f)
6693b3
+    f = -f;
6693b3
+
6693b3
+  return f;
6693b3
+}
6693b3
+
6693b3
+int main(void)
6693b3
+{
6693b3
+  if (foo (-1.0f) != 1.0f)
6693b3
+    abort ();
6693b3
+
6693b3
+  return 0;
6693b3
+}
6693b3
--- gcc/testsuite/g++.dg/opt/ifcvt1.C	2006-10-04 16:28:56.502613000 +0200
6693b3
+++ gcc/testsuite/g++.dg/opt/ifcvt1.C	2006-12-08 12:23:23.000000000 +0100
6693b3
@@ -0,0 +1,17 @@
6693b3
+// { dg-do compile }
6693b3
+// { dg-options "-O2 -fnon-call-exceptions" }
6693b3
+
6693b3
+struct S { ~S () throw () {} };
6693b3
+double bar ();
6693b3
+
6693b3
+int
6693b3
+foo ()
6693b3
+{
6693b3
+  S a;
6693b3
+  int i = 0;
6693b3
+  double c = bar ();
6693b3
+  c = c < 0 ? -c : c;
6693b3
+  if (c <= 1.e-8)
6693b3
+    i += 24;
6693b3
+  return i;
6693b3
+}