Fix integer overflow for widening addition PiperOrigin-RevId: 879354891 Change-Id: I01e10fa062301ecb6fa86ec7d2c8282759534cd9
diff --git a/riscv/riscv_i_instructions.cc b/riscv/riscv_i_instructions.cc index ecdd6bf..baf0afe 100644 --- a/riscv/riscv_i_instructions.cc +++ b/riscv/riscv_i_instructions.cc
@@ -201,7 +201,7 @@ void RiscVIAddw(const Instruction* instruction) { RiscVBinaryOp<RegisterType, IntReg, NarrowIntReg>( instruction, [](NarrowIntReg a, NarrowIntReg b) { - IntReg c = static_cast<IntReg>(a) + static_cast<IntReg>(b); + IntReg c = static_cast<IntReg>(a + b); return c; }); }