[llvm] 75c7e3e - [NFC][InstCombine] Add plain GEP test for (gep i8* X, -(ptrtoint Y)) --> (inttoptr (sub (ptrtoint X), (ptrtoint Y))) fold
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 6 12:00:48 PST 2021
Author: Roman Lebedev
Date: 2021-03-06T23:00:25+03:00
New Revision: 75c7e3e3145f06d85b9580d4a1c9bc7f4b5a9a9e
URL: https://github.com/llvm/llvm-project/commit/75c7e3e3145f06d85b9580d4a1c9bc7f4b5a9a9e
DIFF: https://github.com/llvm/llvm-project/commit/75c7e3e3145f06d85b9580d4a1c9bc7f4b5a9a9e.diff
LOG: [NFC][InstCombine] Add plain GEP test for (gep i8* X, -(ptrtoint Y)) --> (inttoptr (sub (ptrtoint X), (ptrtoint Y))) fold
Added:
Modified:
llvm/test/Transforms/InstCombine/getelementptr.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/getelementptr.ll b/llvm/test/Transforms/InstCombine/getelementptr.ll
index e83422cd26ef..877f20099615 100644
--- a/llvm/test/Transforms/InstCombine/getelementptr.ll
+++ b/llvm/test/Transforms/InstCombine/getelementptr.ll
@@ -1025,6 +1025,21 @@ define i16 @test41([3 x i32] addrspace(1)* %array) {
}
+define i8* @test42i(i8* %c1, i8* %c2) {
+; CHECK-LABEL: @test42i(
+; CHECK-NEXT: [[PTRTOINT:%.*]] = ptrtoint i8* [[C1:%.*]] to i64
+; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint i8* [[C2:%.*]] to i64
+; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], [[PTRTOINT]]
+; CHECK-NEXT: [[GEP:%.*]] = inttoptr i64 [[TMP2]] to i8*
+; CHECK-NEXT: ret i8* [[GEP]]
+;
+ %ptrtoint = ptrtoint i8* %c1 to i64
+ %sub = sub i64 0, %ptrtoint
+ %gep = getelementptr inbounds i8, i8* %c2, i64 %sub
+ ret i8* %gep
+
+}
+
define i8* @test42(i8* %c1, i8* %c2) {
; CHECK-LABEL: @test42(
; CHECK-NEXT: [[PTRTOINT:%.*]] = ptrtoint i8* [[C1:%.*]] to i64
@@ -1035,13 +1050,13 @@ define i8* @test42(i8* %c1, i8* %c2) {
;
%ptrtoint = ptrtoint i8* %c1 to i64
%sub = sub i64 0, %ptrtoint
- %gep = getelementptr inbounds i8, i8* %c2, i64 %sub
+ %gep = getelementptr i8, i8* %c2, i64 %sub
ret i8* %gep
}
-define i16* @test43(i16* %c1, i16* %c2) {
-; CHECK-LABEL: @test43(
+define i16* @test43i(i16* %c1, i16* %c2) {
+; CHECK-LABEL: @test43i(
; CHECK-NEXT: [[PTRTOINT:%.*]] = ptrtoint i16* [[C1:%.*]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint i16* [[C2:%.*]] to i64
; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], [[PTRTOINT]]
@@ -1056,8 +1071,8 @@ define i16* @test43(i16* %c1, i16* %c2) {
}
-define %struct.C* @test44(%struct.C* %c1, %struct.C* %c2) {
-; CHECK-LABEL: @test44(
+define %struct.C* @test44i(%struct.C* %c1, %struct.C* %c2) {
+; CHECK-LABEL: @test44i(
; CHECK-NEXT: [[PTRTOINT:%.*]] = ptrtoint %struct.C* [[C1:%.*]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = ptrtoint %struct.C* [[C2:%.*]] to i64
; CHECK-NEXT: [[TMP2:%.*]] = sub i64 [[TMP1]], [[PTRTOINT]]
More information about the llvm-commits
mailing list