From 001c60ccfeaf9a480a56203418af804ad42e88b9 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Tue, 27 Sep 2022 10:30:00 +0200 Subject: range-ops: Calculate the popcount of a singleton. The legacy popcount folding didn't actually fold singleton ranges. I don't think anyone noticed because there are match.pd patterns that fold __builtin_popcount using the global nonzero bits set by CCP. It's good form to handle this, even without CCP's help. Tested on x86-64 Linux. gcc/ChangeLog: * gimple-range-op.cc (cfn_popcount): Calculate the popcount of a singleton. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/popcount6b.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/popcount6b.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/popcount6b.c (limited to 'gcc/testsuite/gcc.dg/tree-ssa') diff --git a/gcc/testsuite/gcc.dg/tree-ssa/popcount6b.c b/gcc/testsuite/gcc.dg/tree-ssa/popcount6b.c new file mode 100644 index 0000000..90336ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/popcount6b.c @@ -0,0 +1,6 @@ +// { dg-do compile } +// { dg-options "-O2 -fdump-tree-evrp -fno-tree-ccp" } + +#include "popcount6.c" + +// { dg-final { scan-tree-dump "return 1;" "evrp" } } -- cgit v1.1