You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Gandiva] Wrong results with negative integer constants when JIT optimization is on #55613
Describe the bug, including details regarding any error messages, version, and platform.
To reproduce:
Create an int32 field k with rows 0, 1, 2.
Build a projector with if (k == 0) 10 else -5, int32 literals.
Use the default configuration (optimization on).
Evaluate.
The result is [-5, -5, -5]. Expected [10, -5, -5]. With optimization off the result is correct.
It is the same for int16 and for if (k == 0) -5 else 10. int64, -1 and non-negative literals are fine.
Seen on macOS ARM64 with LLVM 21.1.7, main at ab5b42237d.
The symptom depends on the LLVM version:
LLVM 21.1.7: wrong results, as above.
LLVM 23.1.4: assertion Value is not an N-bit unsigned value in the APInt constructor, called from int_constant.
LLVM 18 (CI, Linux and macOS Intel): the IF case returns correct results, for 16, 32 and 64 bits. The i128 constant is wrong on every version tested: i128_constant(-1) is not all ones, and getSExtValue() on it asserts.
LLVMTypes::int_constant builds llvm::APInt(N, val) without the signed flag. In LLVM 21.1.7 the constructor clears the bits above the width only when the signed flag is set, so a negative value narrower than 64 bits is stored with bits set above its width. LLVM 18.1.8 always clears them. For i128 the value is not sign-extended in either version unless the flag is set. GH-45999 hit an assertion on the same line (i32_constant(-1), LLVM 20.1.1). That fix avoided the call and left int_constant unchanged.
Passing std::is_signed<ctype>::value as the signed flag fixes all the cases above.
changed the title [-]Wrong results with negative integer constants when JIT optimization is on[/-][+][C++][Gandiva] Wrong results with negative integer constants when JIT optimization is on[/+]on Nov 14, 2026
Activity
[-]Wrong results with negative integer constants when JIT optimization is on[/-][+][C++][Gandiva] Wrong results with negative integer constants when JIT optimization is on[/+]apacheGH-55613: [C++][Gandiva] Add tests for negative integer constants
apacheGH-55613: [C++][Gandiva] Pass signedness to APInt in LLVMTypes:…
GH-55613: [C++][Gandiva] Fix wrong results for negative integer const…
kou commentedon Nov 27, 2026
Issue resolved by pull request 55607
#55607