[llvm] 83e61d0 - [SeparateConstOffsetFromGEP] Add tests for multiple indices (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 20:21:37 PDT 2024
Author: Nikita Popov
Date: 2024-05-16T12:20:18+09:00
New Revision: 83e61d03deaaa8f4dd8395cfa753af7b38f74b24
URL: https://github.com/llvm/llvm-project/commit/83e61d03deaaa8f4dd8395cfa753af7b38f74b24
DIFF: https://github.com/llvm/llvm-project/commit/83e61d03deaaa8f4dd8395cfa753af7b38f74b24.diff
LOG: [SeparateConstOffsetFromGEP] Add tests for multiple indices (NFC)
Added:
Modified:
llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll b/llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll
index b4119f0b50b4f..a7ca5b93c361d 100644
--- a/llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll
+++ b/llvm/test/Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep.ll
@@ -284,3 +284,29 @@ entry:
%idx3 = getelementptr i8, ptr addrspace(3) %const3, i64 %in.idx2
ret void
}
+
+define void @multiple_index_maybe_neg(ptr %in.ptr, i64 %in.idx1) {
+; CHECK-LABEL: define void @multiple_index_maybe_neg(
+; CHECK-SAME: ptr [[IN_PTR:%.*]], i64 [[IN_IDX1:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[CONST1:%.*]] = getelementptr inbounds [2 x <2 x i8>], ptr [[IN_PTR]], i64 0, i64 1
+; CHECK-NEXT: [[IDX1:%.*]] = getelementptr inbounds [2 x <2 x i8>], ptr [[CONST1]], i64 0, i64 [[IN_IDX1]]
+; CHECK-NEXT: ret void
+;
+ %const1 = getelementptr inbounds [2 x <2 x i8>], ptr %in.ptr, i64 0, i64 1
+ %idx1 = getelementptr inbounds [2 x <2 x i8>], ptr %const1, i64 0, i64 %in.idx1
+ ret void
+}
+
+define void @multiple_index_nonneg(ptr %in.ptr, i64 %in.idx1) {
+; CHECK-LABEL: define void @multiple_index_nonneg(
+; CHECK-SAME: ptr [[IN_PTR:%.*]], i64 [[IN_IDX1:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[IN_IDX1_NNEG:%.*]] = and i64 [[IN_IDX1]], 9223372036854775807
+; CHECK-NEXT: [[CONST1:%.*]] = getelementptr inbounds [2 x <2 x i8>], ptr [[IN_PTR]], i64 0, i64 1
+; CHECK-NEXT: [[IDX1:%.*]] = getelementptr inbounds [2 x <2 x i8>], ptr [[CONST1]], i64 0, i64 [[IN_IDX1_NNEG]]
+; CHECK-NEXT: ret void
+;
+ %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
+ %const1 = getelementptr inbounds [2 x <2 x i8>], ptr %in.ptr, i64 0, i64 1
+ %idx1 = getelementptr inbounds [2 x <2 x i8>], ptr %const1, i64 0, i64 %in.idx1.nneg
+ ret void
+}
More information about the llvm-commits
mailing list