aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-03-02 16:48:39 +0000
committergingerBill <bill@gingerbill.org>2021-03-02 16:48:39 +0000
commitc2794b62a92f6805723ee1b5bed1622858671478 (patch)
treec4b78706ae0e6dc7de52eeaa991534e310327ae3 /src/llvm_backend.cpp
parent4e63ab5edcb1785df2d90c4de6f885dc57e45e7d (diff)
Clean up logic for `<<` and `>>` behaviour
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 0f34f42b0..3c87293c2 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -5826,9 +5826,9 @@ handle_op:
LLVMValueRef lhsval = lhs.value;
LLVMValueRef bits = rhs.value;
- LLVMValueRef max = LLVMConstInt(lb_type(p->module, rhs.type), 8*type_size_of(lhs.type) - 1, false);
+ LLVMValueRef max = LLVMConstInt(lb_type(p->module, rhs.type), 8*type_size_of(lhs.type), false);
- LLVMValueRef less_equal_width = LLVMBuildICmp(p->builder, LLVMIntULE, bits, max, "");
+ LLVMValueRef less_equal_width = LLVMBuildICmp(p->builder, LLVMIntULT, bits, max, "");
res.value = LLVMBuildShl(p->builder, lhsval, bits, "");
LLVMValueRef zero = LLVMConstNull(lb_type(p->module, lhs.type));
@@ -5842,9 +5842,9 @@ handle_op:
LLVMValueRef bits = rhs.value;
bool is_unsigned = is_type_unsigned(type);
- LLVMValueRef max = LLVMConstInt(lb_type(p->module, rhs.type), 8*type_size_of(lhs.type) - 1, false);
+ LLVMValueRef max = LLVMConstInt(lb_type(p->module, rhs.type), 8*type_size_of(lhs.type), false);
- LLVMValueRef less_equal_width = LLVMBuildICmp(p->builder, LLVMIntULE, bits, max, "");
+ LLVMValueRef less_equal_width = LLVMBuildICmp(p->builder, LLVMIntULT, bits, max, "");
bits = LLVMBuildSelect(p->builder, less_equal_width, bits, max, "");
if (is_unsigned) {