소스 검색

shader/arithmetic_integer: Change IAdd to UAdd to avoid signed overflow

Signed integer addition overflow might be undefined behavior. It's free
to change operations to UAdd and use unsigned integers to avoid
potential bugs.
ReinUsesLisp 6 년 전
부모
커밋
2a96bea6a7
1개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      src/video_core/shader/decode/arithmetic_integer.cpp

+ 2 - 2
src/video_core/shader/decode/arithmetic_integer.cpp

@@ -40,12 +40,12 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) {
         op_a = GetOperandAbsNegInteger(op_a, false, instr.alu_integer.negate_a, true);
         op_b = GetOperandAbsNegInteger(op_b, false, instr.alu_integer.negate_b, true);
 
-        Node value = Operation(OperationCode::IAdd, op_a, op_b);
+        Node value = Operation(OperationCode::UAdd, op_a, op_b);
 
         if (instr.iadd.x) {
             Node carry = GetInternalFlag(InternalFlag::Carry);
             Node x = Operation(OperationCode::Select, std::move(carry), Immediate(1), Immediate(0));
-            value = Operation(OperationCode::IAdd, std::move(value), std::move(x));
+            value = Operation(OperationCode::UAdd, std::move(value), std::move(x));
         }
 
         if (instr.generates_cc) {