aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-if-conv.cc
diff options
context:
space:
mode:
authorFilip Kastl <fkastl@suse.cz>2024-10-02 14:14:44 +0200
committerFilip Kastl <fkastl@suse.cz>2024-10-02 14:14:44 +0200
commitffc389cb11a2a61fb89b6034d3f3fe0896b29064 (patch)
tree7220325094ba68b4feb5ff80d6e668e466782742 /gcc/tree-if-conv.cc
parent842fbfa15fff2daae4a4d8a9cbcdf18e22635f78 (diff)
downloadgcc-ffc389cb11a2a61fb89b6034d3f3fe0896b29064.zip
gcc-ffc389cb11a2a61fb89b6034d3f3fe0896b29064.tar.gz
gcc-ffc389cb11a2a61fb89b6034d3f3fe0896b29064.tar.bz2
gimple ssa: Don't use __builtin_popcount in switch exp transform [PR116616]
Switch exponential transformation in the switch conversion pass currently generates tmp1 = __builtin_popcount (var); tmp2 = tmp1 == 1; when inserting code to determine if var is power of two. If the target doesn't support expanding the builtin as special instructions switch conversion relies on this whole pattern being expanded as bitmagic. However, it is possible that other GIMPLE optimizations move the two statements of the pattern apart. In that case the builtin becomes a libgcc call in the final binary. The call is slow and in case of freestanding programs can result in linking error (this bug was originally found while compiling Linux kernel). This patch modifies switch conversion to insert the bitmagic (var ^ (var - 1)) > (var - 1) instead of the builtin. gcc/ChangeLog: PR tree-optimization/116616 * tree-switch-conversion.cc (can_pow2p): Remove this function. (gen_pow2p): Generate bitmagic instead of a builtin. Remove the TYPE parameter. (switch_conversion::is_exp_index_transform_viable): Don't call can_pow2p. (switch_conversion::exp_index_transform): Call gen_pow2p without the TYPE parameter. * tree-switch-conversion.h: Remove m_exp_index_transform_pow2p_type. gcc/testsuite/ChangeLog: PR tree-optimization/116616 * gcc.target/i386/switch-exp-transform-1.c: Don't test for presence of the POPCOUNT internal fn call. Signed-off-by: Filip Kastl <fkastl@suse.cz>
Diffstat (limited to 'gcc/tree-if-conv.cc')
0 files changed, 0 insertions, 0 deletions