re PR middle-end/33181 (Revision 127766 generates bad cmov)
authorH.J. Lu <hongjiu.lu@intel.com>
Sun, 26 Aug 2007 18:24:19 +0000 (18:24 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Sun, 26 Aug 2007 18:24:19 +0000 (11:24 -0700)
gcc/

2007-08-26  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/33181
* ifcvt.c (noce_get_alt_condition): Make sure that the previous
non NOTE insn doesn't cross basic block.
(noce_try_abs): Likewise.
(noce_process_if_block): Likewise.

gcc/testsuite/

2007-08-26  H.J. Lu  <hongjiu.lu@intel.com>

PR middle-end/33181
* gcc.dg/ifelse-2.c: New.

From-SVN: r127810

gcc/ChangeLog
gcc/ifcvt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ifelse-2.c [new file with mode: 0644]

index 1b834ba2a2ba90d3dd8cb154df2d74936e19faa9..0c659f545cda08109170a86a8be1607b4b2dc8cd 100644 (file)
@@ -1,3 +1,11 @@
+2007-08-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/33181
+       * ifcvt.c (noce_get_alt_condition): Make sure that the previous
+       non NOTE insn doesn't cross basic block.
+       (noce_try_abs): Likewise.
+       (noce_process_if_block): Likewise.
+
 2007-08-26  David Edelsohn  <edelsohn@gnu.org>
 
        PR target/33151
index b3cdf3aaaad0904bb481eeaa426bf78bd0e56f23..644a5e1c6ed47af3ecc2f216821375a8bb49fe00 100644 (file)
@@ -1534,6 +1534,7 @@ noce_get_alt_condition (struct noce_if_info *if_info, rtx target,
       /* First, look to see if we put a constant in a register.  */
       prev_insn = prev_nonnote_insn (if_info->cond_earliest);
       if (prev_insn
+         && BLOCK_NUM (prev_insn) == BLOCK_NUM (if_info->cond_earliest)
          && INSN_P (prev_insn)
          && GET_CODE (PATTERN (prev_insn)) == SET)
        {
@@ -1772,6 +1773,7 @@ noce_try_abs (struct noce_if_info *if_info)
     {
       rtx set, insn = prev_nonnote_insn (earliest);
       if (insn
+         && BLOCK_NUM (insn) == BLOCK_NUM (earliest)
          && (set = single_set (insn))
          && rtx_equal_p (SET_DEST (set), c))
        {
@@ -2198,6 +2200,7 @@ noce_process_if_block (struct noce_if_info *if_info)
         COND_EARLIEST to JUMP.  Make sure the relevant data is still
         intact.  */
       if (! insn_b
+         || BLOCK_NUM (insn_b) != BLOCK_NUM (if_info->cond_earliest)
          || !NONJUMP_INSN_P (insn_b)
          || (set_b = single_set (insn_b)) == NULL_RTX
          || ! rtx_equal_p (x, SET_DEST (set_b))
index 8dbd4c2c9e7e526c4fe49ef4af35dc3194a73374..ae2f57b62cc96eedbd264fb252a2a96616e1c2d3 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-26  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR middle-end/33181
+       * gcc.dg/ifelse-2.c: New.
+
 2007-08-26  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/32980
diff --git a/gcc/testsuite/gcc.dg/ifelse-2.c b/gcc/testsuite/gcc.dg/ifelse-2.c
new file mode 100644 (file)
index 0000000..0210fcf
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+{ dg-do run }
+{ dg-options "-O2" }
+*/
+
+extern void abort (void);
+
+enum Status
+{
+  P_ON_LOWER = -4,
+  P_ON_UPPER = -2,
+  P_FREE = -1
+};
+
+void
+foo (enum Status *stat, double newUpper, double lower, double max)
+{
+  if (newUpper >= max)
+    *stat = P_FREE;
+  else if (newUpper == lower)
+    *stat = P_ON_LOWER;
+}
+
+int
+main ()
+{
+  enum Status stat = P_ON_UPPER;
+
+  foo (&stat, 5.0, -10.0, 10.0);
+
+  if (stat != P_ON_UPPER)
+    abort ();
+  return 0;
+}