diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2024-10-02 12:24:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-02 19:24:37 +0000 |
commit | 6810928927e4d12d9a5dd90e672afb096882b730 (patch) | |
tree | ca4f708ce2a69877d5b49fc11fff24870ea01b54 /Python/optimizer.c | |
parent | b85923a0feaae698c811f6c4cf6be018f3725dd5 (diff) | |
download | cpython-6810928927e4d12d9a5dd90e672afb096882b730.tar.gz cpython-6810928927e4d12d9a5dd90e672afb096882b730.zip |
GH-118093: Don't lose confidence when tracing through 100% biased branches (GH-124813)
Diffstat (limited to 'Python/optimizer.c')
-rw-r--r-- | Python/optimizer.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Python/optimizer.c b/Python/optimizer.c index 978649faa04..b876b6c2bd7 100644 --- a/Python/optimizer.c +++ b/Python/optimizer.c @@ -643,14 +643,12 @@ translate_bytecode_to_trace( int bitcount = _Py_popcount32(counter); int jump_likely = bitcount > 8; /* If bitcount is 8 (half the jumps were taken), adjust confidence by 50%. - If it's 16 or 0 (all or none were taken), adjust by 10% - (since the future is still somewhat uncertain). For values in between, adjust proportionally. */ if (jump_likely) { - confidence = confidence * (bitcount + 2) / 20; + confidence = confidence * bitcount / 16; } else { - confidence = confidence * (18 - bitcount) / 20; + confidence = confidence * (16 - bitcount) / 16; } uint32_t uopcode = BRANCH_TO_GUARD[opcode - POP_JUMP_IF_FALSE][jump_likely]; DPRINTF(2, "%d: %s(%d): counter=%04x, bitcount=%d, likely=%d, confidence=%d, uopcode=%s\n", |