[all-commits] [llvm/llvm-project] 0aa9ec: [InstCombine] Fold zext into de-interleaving (fact...
Min-Yih Hsu via All-commits
all-commits at lists.llvm.org
Thu May 28 10:34:44 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0aa9ec6a361002f54deb2a8036410455ee527950
https://github.com/llvm/llvm-project/commit/0aa9ec6a361002f54deb2a8036410455ee527950
Author: Min-Yih Hsu <min.hsu at sifive.com>
Date: 2026-05-28 (Thu, 28 May 2026)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
M llvm/lib/Transforms/InstCombine/InstCombineInternal.h
M llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
M llvm/test/Transforms/InstCombine/ARM/mve-narrow.ll
A llvm/test/Transforms/InstCombine/fold-zext-of-deinterleave.ll
Log Message:
-----------
[InstCombine] Fold zext into de-interleaving (factor=2) instructions (#195330)
Given the following de-interleaving shufflevectors and the consuming
zexts:
```
%f0 = shufflevector <8 x i32> %v, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
%f1 = shufflevector <8 x i32> %v, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
%z0 = zext <4 x i32> %f0 to <4 x i64>
%z1 = zext <4 x i32> %f1 to <4 x i64>
```
We can actually bitcast the input value, `%v`, first into a vector type
with double the element size but half the vector length, before
replacing zexts with simple arithmetics on this new bitcast:
```
%bc = bitcast <8 x i32> %v to <4 x i64>
%z0 = and <4 x i64> %bc, splat (i64 4294967295)
%z1 = lshr <4 x i64> %bc, splat (i64 32)
```
This transformation is almost always benefitial as shufflevector is
generally more expensive than normal arithmetics.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list