@@ -1726,9 +1726,17 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1726
1726
ptr_loads = ptr_loads_copy;
1727
1727
llvm::Value *capacity = LLVM::CreateLoad (*builder,
1728
1728
llvm_utils->dict_api ->get_pointer_to_capacity (right));
1729
- llvm::Value *key_hash = llvm_utils->dict_api ->get_key_hash (capacity, left, dict_type->m_key_type , *module );
1730
-
1731
- tmp = llvm_utils->dict_api ->resolve_collision_for_read_with_bound_check (right, key_hash, left, *module , dict_type->m_key_type , dict_type->m_value_type , true );
1729
+ get_builder0 ();
1730
+ llvm::AllocaInst *res = builder0.CreateAlloca (llvm::Type::getInt1Ty (context), nullptr );
1731
+ llvm_utils->create_if_else (builder->CreateICmpEQ (
1732
+ capacity, llvm::ConstantInt::get (llvm::Type::getInt32Ty (context), llvm::APInt (32 , 0 ))),
1733
+ [&]() {
1734
+ LLVM::CreateStore (*builder, llvm::ConstantInt::get (llvm::Type::getInt1Ty (context), llvm::APInt (1 , 0 )), res);
1735
+ }, [&]() {
1736
+ llvm::Value *key_hash = llvm_utils->dict_api ->get_key_hash (capacity, left, dict_type->m_key_type , *module );
1737
+ LLVM::CreateStore (*builder, llvm_utils->dict_api ->resolve_collision_for_read_with_bound_check (right, key_hash, left, *module , dict_type->m_key_type , dict_type->m_value_type , true ), res);
1738
+ });
1739
+ tmp = LLVM::CreateLoad (*builder, res);
1732
1740
}
1733
1741
1734
1742
void visit_SetContains (const ASR::SetContains_t &x) {
@@ -1748,9 +1756,17 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1748
1756
ptr_loads = ptr_loads_copy;
1749
1757
llvm::Value *capacity = LLVM::CreateLoad (*builder,
1750
1758
llvm_utils->set_api ->get_pointer_to_capacity (right));
1751
- llvm::Value *el_hash = llvm_utils->set_api ->get_el_hash (capacity, left, el_type, *module );
1752
-
1753
- tmp = llvm_utils->set_api ->resolve_collision_for_read_with_bound_check (right, el_hash, left, *module , el_type, false , true );
1759
+ get_builder0 ();
1760
+ llvm::AllocaInst *res = builder0.CreateAlloca (llvm::Type::getInt1Ty (context), nullptr );
1761
+ llvm_utils->create_if_else (builder->CreateICmpEQ (
1762
+ capacity, llvm::ConstantInt::get (llvm::Type::getInt32Ty (context), llvm::APInt (32 , 0 ))),
1763
+ [&]() {
1764
+ LLVM::CreateStore (*builder, llvm::ConstantInt::get (llvm::Type::getInt1Ty (context), llvm::APInt (1 , 0 )), res);
1765
+ }, [&]() {
1766
+ llvm::Value *el_hash = llvm_utils->set_api ->get_el_hash (capacity, left, el_type, *module );
1767
+ LLVM::CreateStore (*builder, llvm_utils->set_api ->resolve_collision_for_read_with_bound_check (right, el_hash, left, *module , el_type, false , true ), res);
1768
+ });
1769
+ tmp = LLVM::CreateLoad (*builder, res);
1754
1770
}
1755
1771
1756
1772
void visit_DictLen (const ASR::DictLen_t& x) {
0 commit comments