MCPcopy Create free account
hub / github.com/apache/arrow / AddFastPath

Method AddFastPath

cpp/src/gandiva/decimal_ir.cc:186–203  ·  view source on GitHub ↗

@brief Fast-path for add Adjust x and y to the same scale, and add them.

Source from the content-addressed store, hash-verified

184/// @brief Fast-path for add
185/// Adjust x and y to the same scale, and add them.
186llvm::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.

Callers

nothing calls this directly

Calls 3

ir_builderFunction · 0.70
scaleMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected