aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-03-30 20:38:04 +0100
committergingerBill <bill@gingerbill.org>2021-03-30 20:38:04 +0100
commit3359d0323a3115601b49ac7d6860c8b15babb491 (patch)
tree7543035a8949c5762f292b601b8a4f0a4fd15d89 /src/ir.cpp
parentfbd01660ee8cff6d17e54e9e4b6ffd4e5011083b (diff)
Change `>>` behaviour in LLVM to prevent stupid UB
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 090967ad8..34d4f79c1 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4642,7 +4642,6 @@ handle_op:
irValue *bit_size = ir_value_constant(type, exact_value_i64(8*type_size_of(type)));
irValue *width_test = ir_emit(proc, ir_instr_binary_op(proc, Token_Lt, bits, bit_size, t_llvm_bool));
-
irValue *zero = ir_value_constant(type, exact_value_i64(0));
irValue *res = ir_emit(proc, ir_instr_binary_op(proc, op, left, bits, type));
return ir_emit_select(proc, width_test, res, zero);
@@ -4656,11 +4655,11 @@ handle_op:
irValue *bits = right;
irValue *bit_size = ir_value_constant(type, exact_value_i64(8*type_size_of(type)));
- irValue *max = ir_value_constant(type, exact_value_i64(8*type_size_of(type)-1));
irValue *width_test = ir_emit(proc, ir_instr_binary_op(proc, Token_Lt, bits, bit_size, t_llvm_bool));
- bits = ir_emit_select(proc, width_test, bits, max);
- return ir_emit(proc, ir_instr_binary_op(proc, op, left, bits, type));
+ irValue *zero = ir_value_constant(type, exact_value_i64(0));
+ irValue *res = ir_emit(proc, ir_instr_binary_op(proc, op, left, bits, type));
+ return ir_emit_select(proc, width_test, res, zero);
}
case Token_AndNot: {