This series addresses two related issues in the avoid-store-forwarding pass.
The PR119795 fix introduced two conservative safety measures: the store_exprs_del mechanism (which blocks forwarding when a deleted store's range overlaps the load) and a hard return that aborts BB analysis on encountering a complex memory operation. Neither targets the actual PR119795 root cause: the bit-insert sequence can clobber hard registers (x86 flags) that are live at the insertion point, breaking flag-dependent sequences such as carry chains. Patch 1 removes store_exprs_del. It is unnecessary for data correctness: in the non-elimination path the load reads all bytes from memory and the bit-insert only overwrites forwarded bytes; in the elimination path the bitmap enforces full coverage. Removing it eliminates an O(n^2) scan over the basic block. Patch 2 adds a targeted fix for the PR119795 root cause: a liveness check that collects hard registers clobbered by the bit-insert sequences (using only CLOBBER side-effects, not the intended SET), computes liveness at the insertion point via df_simulate_one_insn_backwards, and rejects the transformation when a clobbered register is live. On aarch64 (where bfi has no side-effect clobbers) the check is a no-op. Patch 3 replaces the early return on complex memory operations with flush-and-continue, so the pass can find store-forwarding opportunities after barriers such as volatile loads. The two other flush sites (throwing insns, unknown-size memory) already use this pattern. A new test verifies that a store/load pair after a volatile load is detected and forwarded. Konstantinos Eleftheriou (3): avoid-store-forwarding: Remove unnecessary store_exprs_del mechanism avoid-store-forwarding: Reject bit-inserts that clobber live hard regs avoid-store-forwarding: Continue BB analysis after complex memory ops gcc/avoid-store-forwarding.cc | 180 +++++++++++------- .../aarch64/avoid-store-forwarding-6.c | 18 ++ 2 files changed, 130 insertions(+), 68 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/avoid-store-forwarding-6.c -- 2.52.0
