https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127905
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:a4844311b2f48436998f02c8a1c224086426a0cc commit r17-5400-ga4844311b2f48436998f02c8a1c224086426a0cc Author: Jakub Jelinek <[email protected]> Date: Tue Oct 20 12:05:03 2026 +0200 bitintlower: Fix up the single use SSA_NAME optimization [PR127905] The _BitInt lowering contains an optimization, if a SSA_NAME has a single use and if its partition is reused for other SSA_NAMEs, we try to emit a CLOBBER on the underlying variable of the partition after the use if possible, so that GIMPLE opts know it is dead and can optimize better. Already in the past I had to fix this up once, if there are SSA_NAME copies, this can misbehave in some cases due to the coalescing algorithm special casing those. The following testcase shows a different problem. There is an SSA_NAME with a single use, but the definition of the SSA_NAME is before a loop and the use within a loop. In this case emitting a CLOBBER inside of the loop is wrong, the first loop's iteration will use correct value of the underlying var, but second and following iteration will be after a CLOBBER, so e.g. if it is unrolled, the uses in those iterations will be handled as if they read uninitialized memory. The following patch is my attempt to detect the case where the use stmt can be invoked more often than the definition. If def and use are in the same bb, it is IMHO fine, otherwise I compare whether the def and use are in the same loop (that is IMHO also ok as long as no irreducible loop is involved). I've also collected statistics, and this patch in the testsuite emits just 0.137% fewer clobbers than before, so I'm not worried it will pessimize stuff too much. 2026-10-20 Jakub Jelinek <[email protected]> PR tree-optimization/127905 * gimple-lower-bitint.cc (gimple_lower_bitint): Don't add to m_single_use_names versions of SSA_NAMEs where their single use is within a different loop from the definition (or if use is in irreducible loop, in a different bb than def). * gcc.dg/torture/bitint-112.c: New test. Reviewed-by: Richard Biener <[email protected]>
