------- Comment #16 from steven at gcc dot gnu dot org 2006-01-14 16:59 ------- This is still not fixed on mainline, even with the new df implementation. The code to record them is not executed (at least, not on AMD64). The function responsible for recording them is df_bb_refs_record, specifically this code:
ifdef EH_RETURN_DATA_REGNO if ((df->flags & DF_HARD_REGS) && df_has_eh_preds (bb)) { unsigned int i; /* Mark the registers that will contain data for the handler. */ if (current_function_calls_eh_return) for (i = 0; ; ++i) { unsigned regno = EH_RETURN_DATA_REGNO (i); if (regno == INVALID_REGNUM) break; df_ref_record (dflow, regno_reg_rtx[i], ®no_reg_rtx[i], bb, NULL, DF_REF_REG_DEF, DF_REF_ARTIFICIAL | DF_REF_AT_TOP, false); } } #endif But current_function_calls_eh_return is false for the test case, even though the EH_RETURN_DATA_REGNO regs are set: Breakpoint 3, df_bb_refs_record (dflow=0x11203f0, bb=0x2aaaaafaa780) at df-scan.c:1519 1519 if ((df->flags & DF_HARD_REGS) (gdb) p debug_bb(bb) ;; basic block 5, loop depth 1, count 0 ;; prev block 4, next block 6 ;; pred: 4 (ab,abcall,eh) ;; succ: 7 [29.0%] 6 [71.0%] (fallthru,loop_exit) ;; Registers live at start: (nil) (code_label/s 61 28 64 5 8 "" [1 uses]) (note 64 61 62 5 [bb 5] NOTE_INSN_BASIC_BLOCK) (insn 62 64 63 5 (set (reg:DI 65) (reg:DI 0 ax)) 81 {*movdi_1_rex64} (nil) (nil)) (insn 63 62 53 5 (set (reg:DI 66) (reg:DI 1 dx)) 81 {*movdi_1_rex64} (nil) (nil)) (insn 53 63 54 5 (set (reg:CCZ 17 flags) (compare:CCZ (reg:DI 66) (const_int 1 [0x1]))) 2 {cmpdi_1_insn_rex64} (nil) (nil)) (jump_insn 54 53 65 5 (set (pc) (if_then_else (eq (reg:CCZ 17 flags) (const_int 0 [0x0])) (label_ref 30) (pc))) 511 {*jcc_1} (nil) (expr_list:REG_BR_PROB (const_int 2900 [0xb54]) (nil))) ;; Registers live at end: (nil) $5 = void (gdb) next 1524 if (current_function_calls_eh_return) (gdb) p cfun->calls_eh_return $6 = 0 As a result, we still consider insns 62 and 63 to be loop invariant: ;; Function void test01(int) (_Z6test01i) Set in insn 22 is invariant (0), cost 0, depends on Set in insn 25 is invariant (1), cost 0, depends on Set in insn 26 is invariant (2), cost 0, depends on Set in insn 62 is invariant (3), cost 4, depends on Set in insn 63 is invariant (4), cost 4, depends on Set in insn 33 is invariant (5), cost 0, depends on 3 -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24762