diff options
author | Kugan Vivekanandarajah <kuganv@linaro.org> | 2018-11-12 23:43:56 +0000 |
---|---|---|
committer | Kugan Vivekanandarajah <kugan@gcc.gnu.org> | 2018-11-12 23:43:56 +0000 |
commit | 06a6b46a16f9287a98aa6a20366db5542405b9c5 (patch) | |
tree | 8a3db6b424f625a58894ced2c6cd0e7152ca17eb /gcc/tree-scalar-evolution.c | |
parent | 240ae287a189d21ea15c93bba1f774ee69e673a7 (diff) | |
download | gcc-06a6b46a16f9287a98aa6a20366db5542405b9c5.zip gcc-06a6b46a16f9287a98aa6a20366db5542405b9c5.tar.gz gcc-06a6b46a16f9287a98aa6a20366db5542405b9c5.tar.bz2 |
re PR target/86677 (popcount builtin detection is breaking some kernel build)
gcc/ChangeLog:
2018-11-13 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/86677
PR middle-end/87528
* tree-scalar-evolution.c (expression_expensive_p): Make BUILTIN POPCOUNT
as expensive when backend does not define it.
gcc/testsuite/ChangeLog:
2018-11-13 Kugan Vivekanandarajah <kuganv@linaro.org>
PR middle-end/86677
PR middle-end/87528
* g++.dg/tree-ssa/pr86544.C: Run only for target supporting popcount
pattern.
* gcc.dg/tree-ssa/popcount.c: Likewise.
* gcc.dg/tree-ssa/popcount2.c: Likewise.
* gcc.dg/tree-ssa/popcount3.c: Likewise.
* gcc.target/aarch64/popcount4.c: New test.
* lib/target-supports.exp (check_effective_target_popcountl): New.
From-SVN: r266039
Diffstat (limited to 'gcc/tree-scalar-evolution.c')
-rw-r--r-- | gcc/tree-scalar-evolution.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 02174b1..964712c 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -257,7 +257,9 @@ along with GCC; see the file COPYING3. If not see #include "system.h" #include "coretypes.h" #include "backend.h" +#include "target.h" #include "rtl.h" +#include "optabs-query.h" #include "tree.h" #include "gimple.h" #include "ssa.h" @@ -282,6 +284,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple-fold.h" #include "tree-into-ssa.h" #include "builtins.h" +#include "case-cfn-macros.h" static tree analyze_scalar_evolution_1 (struct loop *, tree); static tree analyze_scalar_evolution_for_address_of (struct loop *loop, @@ -3500,6 +3503,36 @@ expression_expensive_p (tree expr) { tree arg; call_expr_arg_iterator iter; + /* Even though is_inexpensive_builtin might say true, we will get a + library call for popcount when backend does not have an instruction + to do so. We consider this to be expenseive and generate + __builtin_popcount only when backend defines it. */ + combined_fn cfn = get_call_combined_fn (expr); + switch (cfn) + { + CASE_CFN_POPCOUNT: + /* Check if opcode for popcount is available in the mode required. */ + if (optab_handler (popcount_optab, + TYPE_MODE (TREE_TYPE (CALL_EXPR_ARG (expr, 0)))) + == CODE_FOR_nothing) + { + machine_mode mode; + mode = TYPE_MODE (TREE_TYPE (CALL_EXPR_ARG (expr, 0))); + scalar_int_mode int_mode; + + /* If the mode is of 2 * UNITS_PER_WORD size, we can handle + double-word popcount by emitting two single-word popcount + instructions. */ + if (is_a <scalar_int_mode> (mode, &int_mode) + && GET_MODE_SIZE (int_mode) == 2 * UNITS_PER_WORD + && (optab_handler (popcount_optab, word_mode) + != CODE_FOR_nothing)) + break; + return true; + } + default: + break; + } if (!is_inexpensive_builtin (get_callee_fndecl (expr))) return true; |