@@ -2573,8 +2573,8 @@ namespace LFortran {
2573
2573
llvm::Module& module ) {
2574
2574
llvm::AllocaInst *is_equal = builder->CreateAlloca (llvm::Type::getInt1Ty (context), nullptr );
2575
2575
LLVM::CreateStore (*builder, llvm::ConstantInt::get (context, llvm::APInt (1 , 1 )), is_equal);
2576
- llvm::Value *a_len = len (l1);
2577
- llvm::Value *b_len = len (l2);
2576
+ llvm::Value *a_len = llvm_utils-> list_api -> len (l1);
2577
+ llvm::Value *b_len = llvm_utils-> list_api -> len (l2);
2578
2578
llvm::Value *cond = builder->CreateICmpEQ (a_len, b_len);
2579
2579
llvm::Function *fn = builder->GetInsertBlock ()->getParent ();
2580
2580
llvm::BasicBlock *thenBB = llvm::BasicBlock::Create (context, " then" , fn);
@@ -2583,6 +2583,8 @@ namespace LFortran {
2583
2583
builder->CreateCondBr (cond, thenBB, elseBB);
2584
2584
builder->SetInsertPoint (thenBB);
2585
2585
llvm::AllocaInst *idx = builder->CreateAlloca (llvm::Type::getInt32Ty (context), nullptr );
2586
+ LLVM::CreateStore (*builder, llvm::ConstantInt::get (
2587
+ context, llvm::APInt (32 , 0 )), idx);
2586
2588
llvm::BasicBlock *loophead = llvm::BasicBlock::Create (context, " loop.head" );
2587
2589
llvm::BasicBlock *loopbody = llvm::BasicBlock::Create (context, " loop.body" );
2588
2590
llvm::BasicBlock *loopend = llvm::BasicBlock::Create (context, " loop.end" );
@@ -2591,17 +2593,17 @@ namespace LFortran {
2591
2593
llvm_utils->start_new_block (loophead);
2592
2594
{
2593
2595
llvm::Value* i = LLVM::CreateLoad (*builder, idx);
2594
- cond = builder->CreateICmpNE (i, a_len);
2595
- builder->CreateCondBr (cond , loopbody, loopend);
2596
+ llvm::Value* cnd = builder->CreateICmpSLT (i, a_len);
2597
+ builder->CreateCondBr (cnd , loopbody, loopend);
2596
2598
}
2597
2599
2598
2600
// body
2599
2601
llvm_utils->start_new_block (loopbody);
2600
2602
{
2601
2603
llvm::Value* i = LLVM::CreateLoad (*builder, idx);
2602
- llvm::Value* left_arg = read_item (l1, i,
2604
+ llvm::Value* left_arg = llvm_utils-> list_api -> read_item (l1, i,
2603
2605
false , module , LLVM::is_llvm_struct (item_type));
2604
- llvm::Value* right_arg = read_item (l2, i,
2606
+ llvm::Value* right_arg = llvm_utils-> list_api -> read_item (l2, i,
2605
2607
false , module , LLVM::is_llvm_struct (item_type));
2606
2608
llvm::Value* res = llvm_utils->is_equal_by_value (left_arg, right_arg, module ,
2607
2609
item_type);
@@ -2619,7 +2621,7 @@ namespace LFortran {
2619
2621
2620
2622
builder->CreateBr (mergeBB);
2621
2623
llvm_utils->start_new_block (elseBB);
2622
- builder-> CreateStore (llvm::ConstantInt::get (context, llvm::APInt (1 , 0 )), is_equal);
2624
+ LLVM:: CreateStore (*builder, llvm::ConstantInt::get (context, llvm::APInt (1 , 0 )), is_equal);
2623
2625
llvm_utils->start_new_block (mergeBB);
2624
2626
return LLVM::CreateLoad (*builder, is_equal);
2625
2627
}
0 commit comments