[llvm] 31c9038 - [SeparateConstOffsetFromGEP] Add additional inbounds preservation tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 19:59:18 PDT 2024
Author: Nikita Popov
Date: 2024-05-16T11:59:07+09:00
New Revision: 31c903890a905d203de3303eaaa63063754ffbca
URL: https://github.com/llvm/llvm-project/commit/31c903890a905d203de3303eaaa63063754ffbca
DIFF: https://github.com/llvm/llvm-project/commit/31c903890a905d203de3303eaaa63063754ffbca.diff
LOG: [SeparateConstOffsetFromGEP] Add additional inbounds preservation tests (NFC)
Adding these for NVPTX because for AMDGPU the problematic -1 case
does not get reordered in the first place.
Added:
Modified:
llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll
index 43dda1ae15176..ec1cbb9e61c03 100644
--- a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll
+++ b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/lower-gep-reorder.ll
@@ -63,3 +63,44 @@ end:
call void asm sideeffect "; use $0", "v"(ptr %idx3)
ret void
}
+
+define void @inboundsPossiblyNegative1(ptr %in.ptr, i64 %in.idx1) {
+; CHECK-LABEL: define void @inboundsPossiblyNegative1(
+; CHECK-SAME: ptr [[IN_PTR:%.*]], i64 [[IN_IDX1:%.*]]) {
+; CHECK-NEXT: [[TMP0:%.*]] = getelementptr <2 x i8>, ptr [[IN_PTR]], i64 [[IN_IDX1]]
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr <2 x i8>, ptr [[TMP0]], i64 1
+; CHECK-NEXT: ret void
+;
+ %const1 = getelementptr inbounds <2 x i8>, ptr %in.ptr, i64 1
+ %idx1 = getelementptr inbounds <2 x i8>, ptr %const1, i64 %in.idx1
+ ret void
+}
+
+define void @inboundsPossiblyNegative2(ptr %in.ptr, i64 %in.idx1) {
+; CHECK-LABEL: define void @inboundsPossiblyNegative2(
+; CHECK-SAME: ptr [[IN_PTR:%.*]], i64 [[IN_IDX1:%.*]]) {
+; CHECK-NEXT: [[IN_IDX1_NNEG:%.*]] = and i64 [[IN_IDX1]], 9223372036854775807
+; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <2 x i8>, ptr [[IN_PTR]], i64 [[IN_IDX1_NNEG]]
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <2 x i8>, ptr [[TMP0]], i64 -1
+; CHECK-NEXT: ret void
+;
+ %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
+ %const1 = getelementptr inbounds <2 x i8>, ptr %in.ptr, i64 -1
+ %idx1 = getelementptr inbounds <2 x i8>, ptr %const1, i64 %in.idx1.nneg
+ ret void
+}
+
+define void @inboundsNonNegative(ptr %in.ptr, i64 %in.idx1) {
+; CHECK-LABEL: define void @inboundsNonNegative(
+; CHECK-SAME: ptr [[IN_PTR:%.*]], i64 [[IN_IDX1:%.*]]) {
+; CHECK-NEXT: [[IDXPROM:%.*]] = and i64 [[IN_IDX1]], 9223372036854775807
+; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <2 x i8>, ptr [[IN_PTR]], i64 [[IDXPROM]]
+; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <2 x i8>, ptr [[TMP0]], i64 1
+; CHECK-NEXT: ret void
+;
+ %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
+ %const1 = getelementptr inbounds <2 x i8>, ptr %in.ptr, i64 1
+ %idx1 = getelementptr inbounds <2 x i8>, ptr %const1, i64 %in.idx1.nneg
+ ret void
+}
+
More information about the llvm-commits
mailing list