aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2023-05-18 21:38:55 +0000
committerAndrew Pinski <apinski@marvell.com>2023-06-04 20:48:32 +0000
commit908e5ab5c11c64ce92f1aa6e12d571ff5eb9d72a (patch)
tree1e6c7a5d28ac6901cfcea6624507e41a9550c748 /libgcc
parentf66e0a94ad7bc18538c8207fc2c86b62e4a51bb2 (diff)
downloadgcc-908e5ab5c11c64ce92f1aa6e12d571ff5eb9d72a.zip
gcc-908e5ab5c11c64ce92f1aa6e12d571ff5eb9d72a.tar.gz
gcc-908e5ab5c11c64ce92f1aa6e12d571ff5eb9d72a.tar.bz2
Improve do_store_flag for single bit comparison against 0
While working something else, I noticed we could improve the following function code generation: ``` unsigned f(unsigned t) { if (t & ~(1<<30)) __builtin_unreachable(); return t != 0; } ``` Right know we just emit a comparison against 0 instead of just a shift right by 30. There is code in do_store_flag which already optimizes `(t & 1<<30) != 0` to `(t >> 30) & 1` (using bit extraction if available). This patch extends it to handle the case where we know t has a nonzero of just one bit set. Changes from v1: * v2: Updated for the bit extraction improvements. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * expr.cc (do_store_flag): Extend the one bit checking case to handle the case where we don't have an and but rather still one bit is known to be non-zero.
Diffstat (limited to 'libgcc')
0 files changed, 0 insertions, 0 deletions