From 45e13b03f372230dbf780f3fa87dd88f388af605 Mon Sep 17 00:00:00 2001 From: arades79 Date: Sat, 11 Feb 2023 13:28:03 -0500 Subject: add static lifetime to constexpr values to force compile time evaluation where possible Signed-off-by: arades79 --- src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp | 2 +- src/shader_recompiler/backend/spirv/emit_spirv_integer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/shader_recompiler/backend') diff --git a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp index 49397c9b2..06599c1b0 100644 --- a/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp +++ b/src/shader_recompiler/backend/glsl/emit_glsl_integer.cpp @@ -39,7 +39,7 @@ void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin // which may be overwritten by the result of the addition if (IR::Inst * overflow{inst.GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) { // https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c - constexpr u32 s32_max{static_cast(std::numeric_limits::max())}; + constexpr static u32 s32_max{static_cast(std::numeric_limits::max())}; const auto sub_a{fmt::format("{}u-{}", s32_max, a)}; const auto positive_result{fmt::format("int({})>int({})", b, sub_a)}; const auto negative_result{fmt::format("int({})GetAssociatedPseudoOperation(IR::Opcode::GetOverflowFromOp)}) { // https://stackoverflow.com/questions/55468823/how-to-detect-integer-overflow-in-c - constexpr u32 s32_max{static_cast(std::numeric_limits::max())}; + constexpr static u32 s32_max{static_cast(std::numeric_limits::max())}; const Id is_positive{ctx.OpSGreaterThanEqual(ctx.U1, a, ctx.u32_zero_value)}; const Id sub_a{ctx.OpISub(ctx.U32[1], ctx.Const(s32_max), a)}; -- cgit v1.2.3