@brief Fast-path for add Adjust x and y to the same scale, and add them.
| 184 | /// @brief Fast-path for add |
| 185 | /// Adjust x and y to the same scale, and add them. |
| 186 | llvm::Value* DecimalIR::AddFastPath(const ValueFull& x, const ValueFull& y) { |
| 187 | auto higher_scale = GetHigherScale(x.scale(), y.scale()); |
| 188 | ADD_TRACE_32("AddFastPath : higher_scale", higher_scale); |
| 189 | |
| 190 | // CPP : x_scaled = IncreaseScale(x_value, higher_scale - x_scale) |
| 191 | auto x_delta = ir_builder()->CreateSub(higher_scale, x.scale()); |
| 192 | auto x_scaled = IncreaseScale(x.value(), x_delta); |
| 193 | ADD_TRACE_128("AddFastPath : x_scaled", x_scaled); |
| 194 | |
| 195 | // CPP : y_scaled = IncreaseScale(y_value, higher_scale - y_scale) |
| 196 | auto y_delta = ir_builder()->CreateSub(higher_scale, y.scale()); |
| 197 | auto y_scaled = IncreaseScale(y.value(), y_delta); |
| 198 | ADD_TRACE_128("AddFastPath : y_scaled", y_scaled); |
| 199 | |
| 200 | auto sum = ir_builder()->CreateAdd(x_scaled, y_scaled); |
| 201 | ADD_TRACE_128("AddFastPath : sum", sum); |
| 202 | return sum; |
| 203 | } |
| 204 | |
| 205 | // @brief Add with overflow check. |
| 206 | /// Adjust x and y to the same scale, add them, and reduce sum to output scale. |
nothing calls this directly
no test coverage detected