[clang] [llvm] [InstCombine] Strip leading zero indices from GEP (PR #155415)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 5 03:10:40 PDT 2025
jayfoad wrote:
This diff looks suspicious to me in function `_ZN22__llvm_libc_22_0_0_git8internal18CharacterConverter8pop_utf8Ev`:
```diff
--- 01-preopt-good.txt 2025-09-05 10:39:57.226224451 +0100
+++ 01-preopt-bad.txt 2025-09-05 10:39:56.149207707 +0100
@@ -11112,10 +11113,10 @@
if.then4: ; preds = %if.end
- %sub7 = add nsw i64 %conv, -1
- %4 = extractelement <4 x i8> <i8 0, i8 -64, i8 -32, i8 -16>, i64 %sub7
- %5 = load i32, ptr %0, align 4, !tbaa !58
+ %4 = add nuw nsw i64 %conv, 4294967295
+ %5 = extractelement <4 x i8> <i8 0, i8 -64, i8 -32, i8 -16>, i64 %4
+ %6 = load i32, ptr %0, align 4, !tbaa !58
%sh_prom = trunc nuw nsw i64 %mul to i32
- %shr = lshr i32 %5, %sh_prom
+ %shr = lshr i32 %6, %sh_prom
%shr.tr = trunc i32 %shr to i8
- %or.narrow = or i8 %4, %shr.tr
- %6 = zext i8 %or.narrow to i32
+ %or.narrow = or i8 %5, %shr.tr
+ %7 = zext i8 %or.narrow to i32
br label %if.end15
```
I am guessing that the `add nsw i64 %conv, -1` vs `add nuw nsw i64 %conv, 4294967295` are the result of transforming some `getelementptr` instructions, and it seems suspicious that the 64-bit offset is small and negative in the good case but large and positive in the bad case.
https://github.com/llvm/llvm-project/pull/155415
More information about the llvm-commits
mailing list