https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123966
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <[email protected]>: https://gcc.gnu.org/g:f1b16d7a17bf2cd8f5071e94384a0893c124e7bf commit r17-75-gf1b16d7a17bf2cd8f5071e94384a0893c124e7bf Author: Eikansh Gupta <[email protected]> Date: Tue Mar 31 16:51:00 2026 +0530 tree-ssa-dce: eliminate dead relaxed atomic loads with no LHS [PR123966] A relaxed atomic load whose result is never used has no observable effect: the value is discarded and __ATOMIC_RELAXED provides no inter-thread synchronisation guarantee. Fix this by adding an early-return check for BUILT_IN_ATOMIC_LOAD_1/2/4/8/16 calls that have no LHS and a compile-time-constant relaxed memory order. PR tree-optimization/123966 gcc/ChangeLog: * tree-ssa-dce.cc (mark_stmt_if_obviously_necessary): Don't mark a relaxed atomic load with no LHS as necessary. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/pr123966.c: New test. Signed-off-by: Eikansh Gupta <[email protected]>
