[llvm] [CVP] Remove Zero-Index GEP (PR #144831)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 23:12:02 PDT 2025
================
@@ -0,0 +1,45 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
+
+define ptr @noop_gep(ptr %ptr, i8 range(i8 0, 1) %index) {
+; CHECK-LABEL: define ptr @noop_gep(
+; CHECK-SAME: ptr [[PTR:%.*]], i8 range(i8 0, 1) [[INDEX:%.*]]) {
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr i1, ptr [[PTR]], i8 [[INDEX]]
+; CHECK-NEXT: ret ptr [[PTR]]
+;
+ %gep = getelementptr i1, ptr %ptr, i8 %index
----------------
dtcxzyw wrote:
```suggestion
%gep = getelementptr i8, ptr %ptr, i64 %index
```
Use i8 as the pointee type and i64 as the index type.
https://github.com/llvm/llvm-project/pull/144831
More information about the llvm-commits
mailing list