[clang] [CIR][CIRGen] Add support for `__sync_val/bool_compare_and_swap` builtins (PR #186529)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 17 15:15:40 PDT 2026
================
@@ -2951,3 +2953,94 @@ int atomic_load_and_store_dynamic_order(int *ptr, int order) {
// OGCG: [[CONTINUE_BLK]]:
// OGCG-NEXT: %{{.+}} = load i32, ptr %[[RES_SLOT]], align 4
}
+
+void cmp_bool_int(int* p, int x, int u) {
+ // CIR-LABEL: @cmp_bool_int
+ // CIR: %[[PTR:.*]] = cir.load{{.*}} {{.*}} : !cir.ptr<!cir.ptr<!s32i>>, !cir.ptr<!s32i>
+ // CIR: %[[CMP:.*]] = cir.load{{.*}} {{.*}} : !cir.ptr<!s32i>, !s32i
+ // CIR: %[[UPD:.*]] = cir.load{{.*}} {{.*}} : !cir.ptr<!s32i>, !s32i
+ // CIR: %[[OLD:.*]], %[[RES:.*]] = cir.atomic.cmpxchg success(seq_cst) failure(seq_cst) syncscope(system) %[[PTR]], %[[CMP]], %[[UPD]] align(4) : (!cir.ptr<!s32i>, !s32i, !s32i) -> (!s32i, !cir.bool)
+ // CIR: cir.store{{.*}} %[[RES]], {{.*}} : !cir.bool, !cir.ptr<!cir.bool>
+
+ // LLVM-LABEL: @cmp_bool_int
----------------
andykaylor wrote:
Can you add OGCG checks?
https://github.com/llvm/llvm-project/pull/186529
More information about the cfe-commits
mailing list