diff options
| author | Vexu <git@vexu.eu> | 2020-03-12 22:42:01 +0200 |
|---|---|---|
| committer | Vexu <git@vexu.eu> | 2020-03-12 22:42:01 +0200 |
| commit | 71d776c3be91f6b4e982b45fbfe03e3696a397f5 (patch) | |
| tree | de9487bd41b3c646f19018e03285730b15c6142d /src/ir.cpp | |
| parent | 6dde769279aaa0cc09d13dd0670b74a8dd24f547 (diff) | |
| download | zig-71d776c3be91f6b4e982b45fbfe03e3696a397f5.tar.gz zig-71d776c3be91f6b4e982b45fbfe03e3696a397f5.zip | |
add note to disabled tests, improve comptime cmpxchg
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index ede403c722..5facc3eb49 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -25215,21 +25215,25 @@ static IrInstGen *ir_analyze_instruction_cmpxchg(IrAnalyze *ira, IrInstSrcCmpxch if (ptr_val == nullptr) return ira->codegen->invalid_inst_gen; - ZigValue *op1_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.base.source_node); - if (op1_val == nullptr) + ZigValue *stored_val = const_ptr_pointee(ira, ira->codegen, ptr_val, instruction->base.base.source_node); + if (stored_val == nullptr) return ira->codegen->invalid_inst_gen; - ZigValue *op2_val = ir_resolve_const(ira, casted_cmp_value, UndefBad); - if (op2_val == nullptr) + ZigValue *expected_val = ir_resolve_const(ira, casted_cmp_value, UndefBad); + if (expected_val == nullptr) + return ira->codegen->invalid_inst_gen; + + ZigValue *new_val = ir_resolve_const(ira, casted_new_value, UndefBad); + if (new_val == nullptr) return ira->codegen->invalid_inst_gen; - bool eql = const_values_equal(ira->codegen, op1_val, op2_val); + bool eql = const_values_equal(ira->codegen, stored_val, expected_val); IrInstGen *result = ir_const(ira, &instruction->base.base, result_type); if (eql) { - ir_analyze_store_ptr(ira, &instruction->base.base, casted_ptr, casted_new_value, false); + copy_const_val(ira->codegen, stored_val, new_val); set_optional_value_to_null(result->value); } else { - set_optional_payload(result->value, op1_val); + set_optional_payload(result->value, stored_val); } return result; } |
