Skip to content

Commit

Permalink
conv:irstollvm: Only load operand in assign conversions when it is ne…
Browse files Browse the repository at this point in the history
…eded.
  • Loading branch information
lkorenc committed Jan 10, 2024
1 parent d42684d commit 14ea1f0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/vast/Conversion/Common/IRsToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,17 +998,18 @@ namespace vast::conv::irstollvm
if (rhs.getType().template isa< hl::LValueType >())
return logical_result::failure();

auto load_lhs = rewriter.create< LLVM::LoadOp >(op.getLoc(), lhs);
auto target_ty = this->convert(op.getSrc().getType());

// Probably the easiest way to compose this (some template specialization would
// require a lot of boilerplate).
auto new_op = [&]()
{
if constexpr (!std::is_same_v< Trg, void >)
if constexpr (!std::is_same_v< Trg, void >) {
auto load_lhs = rewriter.create< LLVM::LoadOp >(op.getLoc(), lhs);
return rewriter.create< Trg >(op.getLoc(), target_ty, load_lhs, rhs);
else
} else {
return rhs;
}
}();

rewriter.create< LLVM::StoreOp >(op.getLoc(), new_op, lhs);
Expand Down

0 comments on commit 14ea1f0

Please sign in to comment.