CPP: return (increase_scale_by <= 0) ? {in_value,false} : {in_value * GetScaleMultiplier(increase_scale_by),true} The return value also indicates if there was an overflow while increasing the scale.
| 140 | // |
| 141 | // The return value also indicates if there was an overflow while increasing the scale. |
| 142 | DecimalIR::ValueWithOverflow DecimalIR::IncreaseScaleWithOverflowCheck( |
| 143 | llvm::Value* in_value, llvm::Value* increase_scale_by) { |
| 144 | llvm::Value* le_zero = |
| 145 | ir_builder()->CreateICmpSLE(increase_scale_by, types()->i32_constant(0)); |
| 146 | |
| 147 | // then block |
| 148 | auto then_lambda = [&] { |
| 149 | ValueWithOverflow ret{in_value, types()->false_constant()}; |
| 150 | return ret.AsStruct(this); |
| 151 | }; |
| 152 | |
| 153 | // else block |
| 154 | auto else_lambda = [&] { |
| 155 | llvm::Value* multiplier = GetScaleMultiplier(increase_scale_by); |
| 156 | return ir_builder()->CreateCall(smul_with_overflow_fn_, {in_value, multiplier}); |
| 157 | }; |
| 158 | |
| 159 | auto ir_struct = |
| 160 | BuildIfElse(le_zero, i128_with_overflow_struct_type_, then_lambda, else_lambda); |
| 161 | return ValueWithOverflow::MakeFromStruct(this, ir_struct); |
| 162 | } |
| 163 | |
| 164 | // CPP: return (reduce_scale_by <= 0) ? |
| 165 | // in_value : in_value / GetScaleMultiplier(reduce_scale_by) |
nothing calls this directly
no test coverage detected