diff options
| author | gingerBill <bill@gingerbill.org> | 2024-08-04 21:17:58 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-08-04 21:17:58 +0100 |
| commit | 7e0fa795e4cb86300bf324f6e0f59279578eefe1 (patch) | |
| tree | 94d104eb318fcd77a615b014a3415a88d5703e5c /src/llvm_backend_expr.cpp | |
| parent | 60bc7f53d227790b7aa342eb6728bbeeb1bf669f (diff) | |
Just compare against `nil` directly if the comparator is known to be `nil` too
Diffstat (limited to 'src/llvm_backend_expr.cpp')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 4bb2676d1..1f0719e13 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -2524,9 +2524,16 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left if (are_types_identical(a, b)) { // NOTE(bill): No need for a conversion } else if (lb_is_const(left) || lb_is_const_nil(left)) { + if (lb_is_const_nil(left)) { + return lb_emit_comp_against_nil(p, op_kind, right); + } left = lb_emit_conv(p, left, right.type); } else if (lb_is_const(right) || lb_is_const_nil(right)) { + if (lb_is_const_nil(right)) { + return lb_emit_comp_against_nil(p, op_kind, left); + } right = lb_emit_conv(p, right, left.type); + } else { Type *lt = left.type; Type *rt = right.type; |