re PR tree-optimization/86927 (Gcc miscompiles at -O3 on valid code)
authorRichard Biener <rguenther@suse.de>
Mon, 27 Aug 2018 14:17:03 +0000 (14:17 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 27 Aug 2018 14:17:03 +0000 (14:17 +0000)
2018-08-27  Richard Biener  <rguenther@suse.de>

PR tree-optimization/86927
* tree-vect-loop.c (vect_create_epilog_for_reduction): Properly
use const cond reduction code.

* gcc.dg/vect/pr86927.c: New testcase.

From-SVN: r263888

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr86927.c [new file with mode: 0644]
gcc/tree-vect-loop.c

index 123d76c86804ddb6219da123071845243bef9393..d27a7a8d78c265816f13eec2732ae3077f1237f8 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86927
+       * tree-vect-loop.c (vect_create_epilog_for_reduction): Properly
+       use const cond reduction code.
+
 2018-08-27  Alexander Monakov  <amonakov@ispras.ru>
 
        PR tree-optimization/85758
index aa957ee561bbc13c8eb2abcc4dd2c04265bbb14f..8ebadb04e875ab89cc9cf0e348025bf389d44a32 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-27  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/86927
+       * gcc.dg/vect/pr86927.c: New testcase.
+
 2018-08-27  David Malcolm  <dmalcolm@redhat.com>
 
        PR 87091
diff --git a/gcc/testsuite/gcc.dg/vect/pr86927.c b/gcc/testsuite/gcc.dg/vect/pr86927.c
new file mode 100644 (file)
index 0000000..794092b
--- /dev/null
@@ -0,0 +1,15 @@
+#include "tree-vect.h"
+
+int a[28];
+int main()
+{
+  check_vect ();
+  a[4] = 1;
+  int c = 1;
+  for (int b = 0; b < 8; b++)
+    if (a[b])
+      c = 0;
+  if (c)
+    abort();
+  return 0;
+}
index d5e35521cefb9dd13b0059fe11e9ec0dc3d6caca..124a4be0a6756a7f0a8cd2f700483c718df84ee5 100644 (file)
@@ -5197,6 +5197,9 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs,
          if (STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info)
              == INTEGER_INDUC_COND_REDUCTION)
            code = induc_code;
+         else if (STMT_VINFO_VEC_REDUCTION_TYPE (stmt_info)
+                  == CONST_COND_REDUCTION)
+           code = STMT_VINFO_VEC_CONST_COND_REDUC_CODE (stmt_info);
          else
            code = MAX_EXPR;
        }