diff options
author | XChy <xxs_chy@outlook.com> | 2025-08-16 02:38:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-15 18:38:04 +0000 |
commit | 3a4a60deffdf5bbe622326b2813583acc37cccce (patch) | |
tree | 6dabbe9bb75f53923745876190ef4d2014f82e6a /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 1dc0005d6d23f36b80358abad6590886c8eed32a (diff) | |
download | llvm-3a4a60deffdf5bbe622326b2813583acc37cccce.zip llvm-3a4a60deffdf5bbe622326b2813583acc37cccce.tar.gz llvm-3a4a60deffdf5bbe622326b2813583acc37cccce.tar.bz2 |
[VectorCombine] Apply InstSimplify in scalarizeOpOrCmp to avoid infinite loop (#153069)
Fixes #153012
As we tolerate unfoldable constant expressions in `scalarizeOpOrCmp`, we
may fold
```llvm
define void @bug(ptr %ptr1, ptr %ptr2, i64 %idx) #0 {
entry:
%158 = insertelement <2 x i64> <i64 5, i64 ptrtoint (ptr @val to i64)>, i64 %idx, i32 0
%159 = or disjoint <2 x i64> splat (i64 2), %158
store <2 x i64> %159, ptr %ptr2
ret void
}
```
to
```llvm
define void @bug(ptr %ptr1, ptr %ptr2, i64 %idx) {
entry:
%.scalar = or disjoint i64 2, %idx
%0 = or <2 x i64> splat (i64 2), <i64 5, i64 ptrtoint (ptr @val to i64)>
%1 = insertelement <2 x i64> %0, i64 %.scalar, i64 0
store <2 x i64> %1, ptr %ptr2, align 16
ret void
}
```
And it would be folded back in `foldInsExtBinop`, resulting in an
infinite loop.
This patch forces scalarization iff InstSimplify can fold the constant
expression.
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
0 files changed, 0 insertions, 0 deletions