From f1a1d3bb123ce870f76d7c78d4654e7e9e7c2568 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 7 Jan 2025 21:56:06 +0000 Subject: [PATCH] Slightly simplify int value lowering. --- toolchain/lower/constant.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index 458dc3581e2e3..fd5ea63baaafd 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -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)