@@ -942,3 +942,56 @@ define i64 @multiple_geps_two_chains_gep_base(ptr %base, i64 %base.idx, i64 %idx
942
942
%d = sub i64 %i2 , %i1
943
943
ret i64 %d
944
944
}
945
+
946
+ define i64 @multiple_geps_inbounds (ptr %base , i64 %idx , i64 %idx2 ) {
947
+ ; CHECK-LABEL: @multiple_geps_inbounds(
948
+ ; CHECK-NEXT: [[D:%.*]] = add i64 [[IDX:%.*]], [[IDX2:%.*]]
949
+ ; CHECK-NEXT: ret i64 [[D]]
950
+ ;
951
+ %p2 = getelementptr inbounds i8 , ptr %base , i64 %idx
952
+ %p3 = getelementptr inbounds i8 , ptr %p2 , i64 %idx2
953
+ %i1 = ptrtoint ptr %base to i64
954
+ %i2 = ptrtoint ptr %p3 to i64
955
+ %d = sub i64 %i2 , %i1
956
+ ret i64 %d
957
+ }
958
+
959
+ define i64 @multiple_geps_nusw (ptr %base , i64 %idx , i64 %idx2 ) {
960
+ ; CHECK-LABEL: @multiple_geps_nusw(
961
+ ; CHECK-NEXT: [[D:%.*]] = add i64 [[IDX:%.*]], [[IDX2:%.*]]
962
+ ; CHECK-NEXT: ret i64 [[D]]
963
+ ;
964
+ %p2 = getelementptr nusw i8 , ptr %base , i64 %idx
965
+ %p3 = getelementptr nusw i8 , ptr %p2 , i64 %idx2
966
+ %i1 = ptrtoint ptr %base to i64
967
+ %i2 = ptrtoint ptr %p3 to i64
968
+ %d = sub i64 %i2 , %i1
969
+ ret i64 %d
970
+ }
971
+
972
+ define i64 @multiple_geps_nuw (ptr %base , i64 %idx , i64 %idx2 ) {
973
+ ; CHECK-LABEL: @multiple_geps_nuw(
974
+ ; CHECK-NEXT: [[D:%.*]] = add i64 [[IDX:%.*]], [[IDX2:%.*]]
975
+ ; CHECK-NEXT: ret i64 [[D]]
976
+ ;
977
+ %p2 = getelementptr nuw i8 , ptr %base , i64 %idx
978
+ %p3 = getelementptr nuw i8 , ptr %p2 , i64 %idx2
979
+ %i1 = ptrtoint ptr %base to i64
980
+ %i2 = ptrtoint ptr %p3 to i64
981
+ %d = sub i64 %i2 , %i1
982
+ ret i64 %d
983
+ }
984
+
985
+
986
+ define i64 @multiple_geps_inbounds_nuw (ptr %base , i64 %idx , i64 %idx2 ) {
987
+ ; CHECK-LABEL: @multiple_geps_inbounds_nuw(
988
+ ; CHECK-NEXT: [[D:%.*]] = add i64 [[IDX:%.*]], [[IDX2:%.*]]
989
+ ; CHECK-NEXT: ret i64 [[D]]
990
+ ;
991
+ %p2 = getelementptr inbounds nuw i8 , ptr %base , i64 %idx
992
+ %p3 = getelementptr inbounds nuw i8 , ptr %p2 , i64 %idx2
993
+ %i1 = ptrtoint ptr %base to i64
994
+ %i2 = ptrtoint ptr %p3 to i64
995
+ %d = sub i64 %i2 , %i1
996
+ ret i64 %d
997
+ }
0 commit comments