diff --git a/stage0/sema.c b/stage0/sema.c index 30c93fcfed..68dcbea8e0 100644 --- a/stage0/sema.c +++ b/stage0/sema.c @@ -526,10 +526,12 @@ static TypeIndex semaTypeOf(Sema* sema, AirInstRef ref) { case AIR_INST_MUL_WRAP: case AIR_INST_ADD_SAT: case AIR_INST_SUB_SAT: + case AIR_INST_MUL_SAT: case AIR_INST_BIT_AND: case AIR_INST_BIT_OR: case AIR_INST_XOR: case AIR_INST_SHL: + case AIR_INST_SHL_SAT: case AIR_INST_SHR: return semaTypeOf(sema, sema->air_inst_datas[inst_idx].bin_op.lhs); // cmp bin_op: result type is bool. @@ -3214,6 +3216,16 @@ static bool analyzeBodyInner( zirArithmetic(sema, block, inst, AIR_INST_SUB_SAT)); i++; continue; + case ZIR_INST_MUL_SAT: + instMapPut(&sema->inst_map, inst, + zirArithmetic(sema, block, inst, AIR_INST_MUL_SAT)); + i++; + continue; + case ZIR_INST_SHL_SAT: + instMapPut(&sema->inst_map, inst, + zirArithmetic(sema, block, inst, AIR_INST_SHL_SAT)); + i++; + continue; // Comparisons: same binary pattern as arithmetic. case ZIR_INST_CMP_LT: diff --git a/stage0/sema_test.zig b/stage0/sema_test.zig index 5578bd66d5..0cafde6616 100644 --- a/stage0/sema_test.zig +++ b/stage0/sema_test.zig @@ -1032,6 +1032,14 @@ test "sema air: sub_sat" { try semaAirRawCheck("export fn f(x: u32, y: u32) u32 { return x -| y; }"); } +test "sema air: mul_sat" { + try semaAirRawCheck("export fn f(x: u32, y: u32) u32 { return x *| y; }"); +} + +test "sema air: shl_sat" { + try semaAirRawCheck("export fn f(x: u32) u32 { return x <<| 1; }"); +} + test "sema air: bit_or" { try semaAirRawCheck("export fn f(x: u32, y: u32) u32 { return x | y; }"); }