Skip to content

Commit fbc65e1

Browse files
committed
Use CreateZExt to generate hash for bool key
1 parent 8fe5878 commit fbc65e1

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/libasr/codegen/llvm_utils.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,19 +1963,7 @@ namespace LCompilers {
19631963
return tuple_hash;
19641964
}
19651965
case ASR::ttypeType::Logical: {
1966-
llvm::AllocaInst *hash_value = builder->CreateAlloca(llvm::Type::getInt32Ty(context), nullptr);
1967-
1968-
llvm::Value* is_key_one = builder->CreateICmpEQ(key,
1969-
llvm::ConstantInt::get(context, llvm::APInt(1, 1)));
1970-
1971-
llvm_utils->create_if_else(is_key_one, [&]() {
1972-
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
1973-
context, llvm::APInt(32, 1)), hash_value);
1974-
}, [=]() {
1975-
LLVM::CreateStore(*builder, llvm::ConstantInt::get(
1976-
context, llvm::APInt(32, 0)), hash_value);
1977-
});
1978-
return hash_value;
1966+
return builder->CreateZExt(key, llvm::Type::getInt32Ty(context));
19791967
}
19801968
default: {
19811969
throw LCompilersException("Hashing " + ASRUtils::type_to_str_python(key_asr_type) +

0 commit comments

Comments
 (0)