在 2023/11/14 上午7:18, Xi Ruoyao 写道: /* snip */ > (define_insn "mem_thread_fence_1" > [(set (match_operand:BLK 0 "" "") > (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER)) > (match_operand:SI 1 "const_int_operand" "")] ;; model > "" > - "dbar\t0") > + { > + enum memmodel model = memmodel_base (INTVAL (operands[1])); > + > + switch (model) > + { > + case MEMMODEL_ACQUIRE: > + case MEMMODEL_CONSUME: Hi, * Before calling this template, the function get_memmodel is called to process memmodel, which has a piece of code: * /* Workaround for Bugzilla 59448. GCC doesn't track consume properly, so be conservative and promote consume to acquire. */ if (val == MEMMODEL_CONSUME) val = MEMMODEL_ACQUIRE; * * So I think MEMMODEL_CONSUME don't need to be processed here either. Otherwise is OK. * Thanks. > + /* Consume is implemented using the stronger acquire memory order > + because of a deficiency in C++11's semantics. */ > + return "dbar\t0b10100"; > + case MEMMODEL_RELEASE: > + return "dbar\t0b10010"; > + case MEMMODEL_ACQ_REL: > + case MEMMODEL_SEQ_CST: > + return "dbar\t0b10000"; > + default: > + /* GCC internal: "For the '__ATOMIC_RELAXED' model no instructions > + need to be issued and this expansion is not invoked." > + Other values should not be returned by memmodel_base. */ > + gcc_unreachable (); > + } > + }) > > ;; Atomic memory operations. >