From: Philipp Tomsich Date: Mon, 23 Feb 2026 19:22:03 +0000 (+0100) Subject: fold-mem-offsets: Clarify why do_analysis pre-marks the memory insn X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4287deacbbee32d165d98e47dd01a60069cdcedb;p=thirdparty%2Fgcc.git fold-mem-offsets: Clarify why do_analysis pre-marks the memory insn The bitmap_set_bit call before fold_offsets in do_analysis is intentional: fold_offsets requires all uses of a definition to already be in can_fold_insns before it will mark the definition as foldable. Pre-marking the memory instruction (which is the root use) is necessary for its address definitions to pass this check during the DFS. Replace the generic comment with one that explains this dependency. gcc/ChangeLog: * fold-mem-offsets.cc (do_analysis): Revise comment. --- diff --git a/gcc/fold-mem-offsets.cc b/gcc/fold-mem-offsets.cc index 1cd2dc036c2..17c92e104bd 100644 --- a/gcc/fold-mem-offsets.cc +++ b/gcc/fold-mem-offsets.cc @@ -653,7 +653,10 @@ do_analysis (rtx_insn *insn) print_rtl_single (dump_file, insn); } - /* Analyse folding opportunities for this memory instruction. */ + /* Mark this memory instruction as foldable before the DFS so that its + address definitions can see it in can_fold_insns during analysis. + This is required because fold_offsets checks that all uses of a + definition are in can_fold_insns before marking the definition. */ bitmap_set_bit (&can_fold_insns, INSN_UID (insn)); fold_offsets (insn, reg, true, NULL); }