aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-data-ref.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2024-07-27 15:16:19 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2024-07-27 15:16:19 +0100
commit928116e94a5a8a995dffd926af58abfa7286e78e (patch)
tree0ca3ac6ebfa0d6cf48604b4fc19ba79ddb4949d0 /gcc/tree-data-ref.c
parentf793be787135ce7c52b169bf053af225b4828945 (diff)
downloadgcc-928116e94a5a8a995dffd926af58abfa7286e78e.zip
gcc-928116e94a5a8a995dffd926af58abfa7286e78e.tar.gz
gcc-928116e94a5a8a995dffd926af58abfa7286e78e.tar.bz2
Fold ctz(-x) and ctz(abs(x)) as ctz(x) in match.pd.
The subject line pretty much says it all; the count-trailing-zeros function of -X and abs(X) produce the same result as count-trailing-zeros of X. This transformation eliminates a negation which may potentially overflow with an equivalent expression that doesn't [much like the analogous abs(-X) simplification in match.pd]. I'd noticed this -X equivalence, which isn't mentioned in Hacker's Delight, investigating whether ranger's non_zero_bits can help determine whether an integer variable may be converted to a floating point type exactly (without raising FE_INEXACT), but it turns out this observation isn't novel, as (disappointingly) LLVM already performs this same folding. 2024-07-27 Roger Sayle <roger@nextmovesoftware.com> Andrew Pinski <quic_apinski@quicinc.com> gcc/ChangeLog * match.pd (ctz (-X) => ctz (X)): New simplification. (ctz (abs (X)) => ctz (X)): Likewise. gcc/testsuite/ChangeLog * gcc.dg/fold-ctz-1.c: New test case. * gcc.dg/fold-ctz-2.c: Likewise.
Diffstat (limited to 'gcc/tree-data-ref.c')
0 files changed, 0 insertions, 0 deletions