Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slightly simplify int value lowering. #4767

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions toolchain/lower/constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,9 @@ static auto EmitAsConstant(ConstantContext& context, SemIR::IntValue inst)
return int_literal_value;
}

auto val = context.sem_ir().ints().Get(inst.int_id);
int bit_width = int_type->getBitWidth();
bool is_signed =
context.sem_ir().types().GetIntTypeInfo(inst.type_id).is_signed;
return llvm::ConstantInt::get(type, is_signed ? val.sextOrTrunc(bit_width)
: val.zextOrTrunc(bit_width));
auto val = context.sem_ir().ints().GetAtWidth(inst.int_id, bit_width);
return llvm::ConstantInt::get(type, val);
}

static auto EmitAsConstant(ConstantContext& context, SemIR::Namespace inst)
Expand Down
Loading