[llvm] [AggressiveInstCombine] Fix crash when folding consecutive loads into a type smaller than the combined load (PR #207229)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 5 05:28:47 PDT 2026
https://github.com/dtcxzyw approved this pull request.
LGTM. Although I'd prefer to reject this transformation when the load size is larger than the target type. The only useful pattern supported by this patch is a case where a load is partially used:
```
define i32 @test(ptr %p) {
%p1 = getelementptr i8, ptr %p, i64 3
%l1 = load i24, ptr %p, align 1
%l2 = load i16, ptr %p1, align 1
%zext1 = zext i24 %l1 to i32
%zext2 = zext i16 %l2 to i32
%shl = shl i32 %zext2, 24
%or = or i32 %shl, %zext1
ret i32 %or
}
```
But I am not sure how useful it is, as it is likely to be rejected by the legal type check above...
Even if we choose the smaller one between WiderType and ZextType as the load type, its usefulness in the real world is still questionable.
https://github.com/llvm/llvm-project/pull/207229
More information about the llvm-commits
mailing list