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