re PR target/84986 (Performance regression: loop no longer vectorized (x86-64))
authorRichard Biener <rguenther@suse.de>
Tue, 20 Mar 2018 14:35:46 +0000 (14:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 20 Mar 2018 14:35:46 +0000 (14:35 +0000)
2018-03-20  Richard Biener  <rguenther@suse.de>

PR target/84986
* config/i386/i386.c (ix86_add_stmt_cost): Only cost
sign-conversions as zero, fall back to standard scalar_stmt
cost for the rest.

* gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c: New testcase.

From-SVN: r258684

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c [new file with mode: 0644]

index f47c1922f69bd9d26cfaba9e5b589f81f1108008..18d727e8ee3503bc31828f61aad0dc018399e117 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR target/84986
+       * config/i386/i386.c (ix86_add_stmt_cost): Only cost
+       sign-conversions as zero, fall back to standard scalar_stmt
+       cost for the rest.
+
 2018-03-20  Martin Liska  <mliska@suse.cz>
 
        PR ipa/84825
index 5b1e962dedb04b220c9cc717580b9bddba7619b8..3b264318f503425f0741f68467371eade254f0ba 100644 (file)
@@ -50462,7 +50462,11 @@ ix86_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind,
          }
          break;
        case NOP_EXPR:
-         stmt_cost = 0;
+         /* Only sign-conversions are free.  */
+         if (tree_nop_conversion_p
+               (TREE_TYPE (gimple_assign_lhs (stmt_info->stmt)),
+                TREE_TYPE (gimple_assign_rhs1 (stmt_info->stmt))))
+           stmt_cost = 0;
          break;
 
        case BIT_IOR_EXPR:
index 6c918c0065bfb0d3be8d5650616c093b64e5c687..f88a09842fa2846afb6c3b52e24dfd10e6892a5a 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-20  Richard Biener  <rguenther@suse.de>
+
+       PR target/84986
+       * gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c: New testcase.
+
 2018-03-20  Martin Liska  <mliska@suse.cz>
 
        PR ipa/84825
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr84986.c
new file mode 100644 (file)
index 0000000..b6dc385
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_long } */
+
+int N;
+long fn1(void) {
+  short i;
+  long a;
+  i = a = 0;
+  while (i < N)
+    a -= i++;
+  return a;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */