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

Method IncreaseScaleWithOverflowCheck

cpp/src/gandiva/decimal_ir.cc:143–163  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

GetScaleMultiplierFunction · 0.85
AsStructMethod · 0.80
ir_builderFunction · 0.70
typesFunction · 0.70

Tested by

no test coverage detected