diff options
author | zGoldthorpe <Zach.Goldthorpe@amd.com> | 2025-08-15 12:48:32 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-15 12:48:32 -0600 |
commit | 82caa251d4e145b54ea76236213617076f254c2b (patch) | |
tree | 9eb95a4f560bb42851fd64e30c6f46830f40da79 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 758c6852c3ffe6b5e259cafadd811e60d8c276fb (diff) | |
download | llvm-82caa251d4e145b54ea76236213617076f254c2b.zip llvm-82caa251d4e145b54ea76236213617076f254c2b.tar.gz llvm-82caa251d4e145b54ea76236213617076f254c2b.tar.bz2 |
[InstCombine] Fold integer unpack/repack patterns through ZExt (#153583)
This patch explicitly enables the InstCombiner to fold integer
unpack/repack patterns such as
```llvm
define i64 @src_combine(i32 %lower, i32 %upper) {
%base = zext i32 %lower to i64
%u.0 = and i32 %upper, u0xff
%z.0 = zext i32 %u.0 to i64
%s.0 = shl i64 %z.0, 32
%o.0 = or i64 %base, %s.0
%r.1 = lshr i32 %upper, 8
%u.1 = and i32 %r.1, u0xff
%z.1 = zext i32 %u.1 to i64
%s.1 = shl i64 %z.1, 40
%o.1 = or i64 %o.0, %s.1
%r.2 = lshr i32 %upper, 16
%u.2 = and i32 %r.2, u0xff
%z.2 = zext i32 %u.2 to i64
%s.2 = shl i64 %z.2, 48
%o.2 = or i64 %o.1, %s.2
%r.3 = lshr i32 %upper, 24
%u.3 = and i32 %r.3, u0xff
%z.3 = zext i32 %u.3 to i64
%s.3 = shl i64 %z.3, 56
%o.3 = or i64 %o.2, %s.3
ret i64 %o.3
}
; =>
define i64 @tgt_combine(i32 %lower, i32 %upper) {
%base = zext i32 %lower to i64
%upper.zext = zext i32 %upper to i64
%s.0 = shl nuw i64 %upper.zext, 32
%o.3 = or disjoint i64 %s.0, %base
ret i64 %o.3
}
```
Alive2 proofs: [YAy7ny](https://alive2.llvm.org/ce/z/YAy7ny)
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions