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

Method ReduceScale

cpp/src/gandiva/decimal_ir.cc:168–181  ·  view source on GitHub ↗

CPP: return (reduce_scale_by <= 0) ? in_value : in_value / GetScaleMultiplier(reduce_scale_by) ReduceScale cannot cause an overflow.

Source from the content-addressed store, hash-verified

166//
167// ReduceScale cannot cause an overflow.
168llvm::Value* DecimalIR::ReduceScale(llvm::Value* in_value, llvm::Value* reduce_scale_by) {
169 auto le_zero = ir_builder()->CreateICmpSLE(reduce_scale_by, types()->i32_constant(0));
170 // then block
171 auto then_lambda = [&] { return in_value; };
172
173 // else block
174 auto else_lambda = [&] {
175 // TODO : handle rounding.
176 llvm::Value* multiplier = GetScaleMultiplier(reduce_scale_by);
177 return ir_builder()->CreateSDiv(in_value, multiplier);
178 };
179
180 return BuildIfElse(le_zero, types()->i128_type(), then_lambda, else_lambda);
181}
182
183/// @brief Fast-path for add
184/// Adjust x and y to the same scale, and add them.

Callers

nothing calls this directly

Calls 3

GetScaleMultiplierFunction · 0.85
ir_builderFunction · 0.70
typesFunction · 0.70

Tested by

no test coverage detected