aboutsummaryrefslogtreecommitdiff
path: root/gcc/cppbuiltin.h
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-11-20 10:00:09 +0100
committerJakub Jelinek <jakub@redhat.com>2023-11-20 10:00:09 +0100
commitd0b6b7f8a6b8115b033441590a6304fb088d193c (patch)
tree59a53cfc6bdaae051b44e913d0b6d06b45a19893 /gcc/cppbuiltin.h
parent99fad213d5d457162be00d873cd655fe402ca91a (diff)
downloadgcc-d0b6b7f8a6b8115b033441590a6304fb088d193c.zip
gcc-d0b6b7f8a6b8115b033441590a6304fb088d193c.tar.gz
gcc-d0b6b7f8a6b8115b033441590a6304fb088d193c.tar.bz2
tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693]
Per the earlier discussions on this PR, the following patch folds popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) if the corresponding popcount optab isn't implemented (I think any double-word popcount or call will be necessarily slower than the above cheap 3 op check and even for -Os larger or same size). I've noticed e.g. C++ aligned new starts with std::has_single_bit which does popcount (x) == 1. As a follow-up, I'm considering changing in this routine the popcount call to IFN_POPCOUNT with 2 arguments and during expansion test costs. 2023-11-20 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/90693 * tree-ssa-math-opts.cc (match_single_bit_test): New function. (math_opts_dom_walker::after_dom_children): Call it for EQ_EXPR and NE_EXPR assignments and GIMPLE_CONDs. * gcc.target/i386/pr90693.c: New test.
Diffstat (limited to 'gcc/cppbuiltin.h')
0 files changed, 0 insertions, 0 deletions