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]

Fix i386 cmov/cstore/cbranch patterns


Hi,
this patch fixes missed cmov conversion I noticed while looking into PR53346. It effectively
reverts patch http://gcc.gnu.org/ml/gcc-patches/2010-07/msg02326.html

I believe it is mistaken - it chnaged comparison_operator to unordered_comparison_operator
on the basis that those patterns are integer only. This is not right. While the cmov
is an integer pattern, it may depend on any FP conditional so unordered comparision make
perfect sense.

Sadly this patch only makes rnflow regression to happen at -O2, too (i.e. not require
-ftree-if-convert) for reasons described in the PR.

The missing if conversion is regression to pre-2010 GCC releases.

Bootstrapped/regtested x86_64-linux, will commit it tomorrow if there are no objections

	PR target/53346
	* config/i386/i386.md (cbranch<mode>4): Use comparison_operator predicate
	for operator0.
	(cstore<mode>4): Ditto for operator1.
	(mov<SWIM:mode>cc): Ditto.

	* gcc.target/i386/cmov9.c: New testcase.

Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 193503)
+++ config/i386/i386.md	(working copy)
@@ -964,7 +964,7 @@
 	(compare:CC (match_operand:SDWIM 1 "nonimmediate_operand")
 		    (match_operand:SDWIM 2 "<general_operand>")))
    (set (pc) (if_then_else
-	       (match_operator 0 "ordered_comparison_operator"
+	       (match_operator 0 "comparison_operator"
 		[(reg:CC FLAGS_REG) (const_int 0)])
 	       (label_ref (match_operand 3))
 	       (pc)))]
@@ -982,7 +982,7 @@
 	(compare:CC (match_operand:SWIM 2 "nonimmediate_operand")
 		    (match_operand:SWIM 3 "<general_operand>")))
    (set (match_operand:QI 0 "register_operand")
-	(match_operator 1 "ordered_comparison_operator"
+	(match_operator 1 "comparison_operator"
 	  [(reg:CC FLAGS_REG) (const_int 0)]))]
   ""
 {
@@ -16120,7 +16120,7 @@
 
 (define_expand "mov<mode>cc"
   [(set (match_operand:SWIM 0 "register_operand")
-	(if_then_else:SWIM (match_operand 1 "ordered_comparison_operator")
+	(if_then_else:SWIM (match_operand 1 "comparison_operator")
 			   (match_operand:SWIM 2 "<general_operand>")
 			   (match_operand:SWIM 3 "<general_operand>")))]
   ""
Index: testsuite/gcc.target/i386/cmov9.c
===================================================================
--- testsuite/gcc.target/i386/cmov9.c	(revision 0)
+++ testsuite/gcc.target/i386/cmov9.c	(working copy)
@@ -0,0 +1,14 @@
+/* PR target/53346 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=opteron" } */
+/* { dg-final { scan-assembler "cmov" } } */
+float a[10000];
+float b[10000];
+t()
+{
+  int mi = 0,i;
+  for (i=0;i<1000;i++)
+    if (a[i]<b[i])
+      mi = i;
+  return mi;
+}


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