[opt](column) Inline column creation to enable cast vectorization (#69840)

### What problem does this PR solve?

Issue Number: N/A

Problem Summary:

Some simple CAST loops remain scalar because
`COWHelper::create(Args&&...)` is not inlined. Root cause: forwarding a
row-count lvalue passes its address to the factory. When output stores
may alias that escaped variable, the compiler cannot prove the loop
bound is invariant and reports `UnsupportedUncountableLoop`.

On x86 with Clang 20.1.8, `-O3` and AVX2, the factory exceeds the inline
threshold for INT-to-BIGINT (cost 260 vs. 250) and
numeric/Decimal-to-BOOLEAN (255 vs. 250). This is not ARM-specific. Mark
the small factory wrapper `ALWAYS_INLINE` so the compiler can see
through column construction and optimize affected callers.

### Release note

None

### Check List (For Author)

- Test
- [x] Manual test: compiled `function_cast_int.cpp` before/after with
Clang optimization remarks and inspected assembly. The non-null
INT-to-BIGINT loop changes from scalar code to AVX2 `vpmovsxdq`, with
vectorization width 4 and interleave count 4. The null-map path still
has a separate vectorization blocker.
- [x] Manual test: diagnostic compilation of `function_cast_bool.cpp`
confirms the same escaped-bound blocker in 26 numeric/Decimal-to-BOOLEAN
instances; an isolated temporary-row-count experiment removes that
blocker. This BOOLEAN experiment validates the cause, not the final
patch across every instance.
- [x] Formatting, `git diff --check`, and
`build-support/check-build-hygiene.sh` passed.
- Full BE build, runtime benchmarks, SQL regression tests and ARM
recompilation were not run. In the INT translation-unit experiment,
object text grows from 448,711 to 478,128 bytes (about 6.6%); runtime
speedup has not been measured.
- Behavior changed:
    - [x] No. SQL conversion semantics are unchanged.
- Does this need documentation?
    - [x] No.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
This commit is contained in:
Mryange authored and Your Name committed 2026-10-30 01:57:44 +00:00
1 parent 71eecdfc8b
commit be501916a8
1 file changed
+1 -1
+1 -1
View File
@@ -430,7 +430,7 @@ public:
// | ~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~
// ColumnPtr res_data_column = ColumnUInt8::create(1, 1);
template <typename... Args>
static MutablePtr create(Args&&... args) {
ALWAYS_INLINE static MutablePtr create(Args&&... args) {
return MutablePtr(new Derived(std::forward<Args>(args)...));
}
#include "common/compile_check_avoid_end.h"