[flang-commits] [clang] [flang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)
Yingwei Zheng via flang-commits
flang-commits at lists.llvm.org
Thu Dec 21 05:58:47 PST 2023
dtcxzyw wrote:
Another example:
```
diff --git a/bench/hermes/optimized/Sorting.cpp.ll b/bench/hermes/optimized/Sorting.cpp.ll
index 1a808c47..e03089ca 100644
--- a/bench/hermes/optimized/Sorting.cpp.ll
+++ b/bench/hermes/optimized/Sorting.cpp.ll
@@ -41,20 +41,22 @@ if.end: ; preds = %entry
%call5.i.i.i.i.i.i = tail call noalias noundef nonnull ptr @_Znwm(i64 noundef %mul.i.i.i.i.i.i) #9
store ptr %call5.i.i.i.i.i.i, ptr %index, align 8
%add.ptr.i.i.i = getelementptr inbounds i32, ptr %call5.i.i.i.i.i.i, i64 %conv
- %_M_end_of_storage.i.i.i = getelementptr inbounds %"struct.std::_Vector_base<unsigned int, std::allocator<unsigned int>>::_Vector_impl_data", ptr %index, i64 0, i32 2
+ %_M_end_of_storage.i.i.i = getelementptr inbounds i8, ptr %index, i64 16
store ptr %add.ptr.i.i.i, ptr %_M_end_of_storage.i.i.i, align 8
store i32 0, ptr %call5.i.i.i.i.i.i, align 4
- %incdec.ptr.i.i.i.i.i = getelementptr i32, ptr %call5.i.i.i.i.i.i, i64 1
- %cmp.i.i.i.i.i.i.i = icmp eq i32 %sub, 1
+ %incdec.ptr.i.i.i.i.i = getelementptr i8, ptr %call5.i.i.i.i.i.i, i64 4
+ %sub.i.i.i.i.i = add nsw i64 %conv, -1
+ %cmp.i.i.i.i.i.i.i = icmp eq i64 %sub.i.i.i.i.i, 0
br i1 %cmp.i.i.i.i.i.i.i, label %_ZNSt6vectorIjSaIjEEC2EmRKS0_.exit, label %if.end.i.i.i.i.i.i.i
if.end.i.i.i.i.i.i.i: ; preds = %if.end
%1 = add nsw i64 %mul.i.i.i.i.i.i, -4
tail call void @llvm.memset.p0.i64(ptr align 4 %incdec.ptr.i.i.i.i.i, i8 0, i64 %1, i1 false)
+ %add.ptr.i.i.i.i.i.i.i = getelementptr inbounds i32, ptr %incdec.ptr.i.i.i.i.i, i64 %sub.i.i.i.i.i
br label %_ZNSt6vectorIjSaIjEEC2EmRKS0_.exit
_ZNSt6vectorIjSaIjEEC2EmRKS0_.exit: ; preds = %if.end, %if.end.i.i.i.i.i.i.i
- %__first.addr.0.i.i.i.i.i = phi ptr [ %incdec.ptr.i.i.i.i.i, %if.end ], [ %add.ptr.i.i.i, %if.end.i.i.i.i.i.i.i ]
+ %__first.addr.0.i.i.i.i.i = phi ptr [ %incdec.ptr.i.i.i.i.i, %if.end ], [ %add.ptr.i.i.i.i.i.i.i, %if.end.i.i.i.i.i.i.i ]
store ptr %__first.addr.0.i.i.i.i.i, ptr %0, align 8
%cmp116.not = icmp eq i32 %end, %begin
br i1 %cmp116.not, label %for.end, label %for.body
```
https://github.com/llvm/llvm-project/pull/68882
More information about the flang-commits
mailing list