From 26d815a3e587ac04dbd63eec3fb5aecb04db7242 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 11 Sep 2019 10:34:41 +0200 Subject: [PATCH] re PR tree-optimization/91723 (builtin fma is not optimized or vectorized as *+) PR tree-optimization/91723 * tree-vect-stmts.c (vectorizable_call): Use types_compatible_p check instead of pointer equality when checking if argument vectypes are the same. * gcc.dg/vect/vect-fma-3.c: New test. From-SVN: r275634 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gcc.dg/vect/vect-fma-3.c | 17 +++++++++++++++++ gcc/tree-vect-stmts.c | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-fma-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 360e606f47e..33b43862051 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2019-09-11 Jakub Jelinek + PR tree-optimization/91723 + * tree-vect-stmts.c (vectorizable_call): Use types_compatible_p check + instead of pointer equality when checking if argument vectypes are + the same. + PR middle-end/91725 * match.pd ((A / (1 << B)) -> (A >> B)): Call tree_nonzero_bits instead of get_nonzero_bits, only call it for integral types. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8ef80620c08..d4488b6789c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-09-11 Jakub Jelinek + PR tree-optimization/91723 + * gcc.dg/vect/vect-fma-3.c: New test. + PR middle-end/91725 * gcc.c-torture/compile/pr91725.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/vect-fma-3.c b/gcc/testsuite/gcc.dg/vect/vect-fma-3.c new file mode 100644 index 00000000000..b231a328fa5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-fma-3.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/91723 */ +/* { dg-do compile { target { scalar_all_fma || { i?86-*-* x86_64-*-* } } } } */ +/* { dg-additional-options "-mfma" { target { i?86-*-* x86_64-*-* } } } */ + +void +foo (double *restrict r, const double *restrict a, + const double *restrict b, const double *restrict c) +{ + for (int i = 0; i < 1024; i++) + { + double x = __builtin_fma (a[i], b[i], c[i]); + x = __builtin_fma (a[i], b[i], x); + r[i] = x; + } +} + +/* { dg-final { scan-tree-dump-times "LOOP VECTORIZED" 1 "vect" { target vect_double } } } */ diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index dd9d45a9547..edc7e0de4d3 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3308,7 +3308,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, if (!vectype_in) vectype_in = vectypes[i]; else if (vectypes[i] - && vectypes[i] != vectype_in) + && !types_compatible_p (vectypes[i], vectype_in)) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, -- 2.30.2