-define i8* @test42(i8* %c1, i8* %c2) {
- %ptrtoint = ptrtoint i8* %c1 to i64
- %sub = sub i64 0, %ptrtoint
- %gep = getelementptr inbounds i8* %c2, i64 %sub
- ret i8* %gep
-
-; CHECK-LABEL: @test42(
-; CHECK-NEXT: [[PTRTOINT1:%.*]] = ptrtoint i8* %c1 to i64
-; CHECK-NEXT: [[PTRTOINT2:%.*]] = ptrtoint i8* %c2 to i64
-; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[PTRTOINT2]], [[PTRTOINT1]]
-; CHECK-NEXT: [[INTTOPTR:%.*]] = inttoptr i64 [[SUB]] to i8*
-; CHECK-NEXT: ret i8* [[INTTOPTR]]
-}
-
-define i16* @test43(i16* %c1, i16* %c2) {
- %ptrtoint = ptrtoint i16* %c1 to i64
- %sub = sub i64 0, %ptrtoint
- %shr = ashr i64 %sub, 1
- %gep = getelementptr inbounds i16* %c2, i64 %shr
- ret i16* %gep
-
-; CHECK-LABEL: @test43(
-; CHECK-NEXT: [[PTRTOINT1:%.*]] = ptrtoint i16* %c1 to i64
-; CHECK-NEXT: [[PTRTOINT2:%.*]] = ptrtoint i16* %c2 to i64
-; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[PTRTOINT2]], [[PTRTOINT1]]
-; CHECK-NEXT: [[INTTOPTR:%.*]] = inttoptr i64 [[SUB]] to i16*
-; CHECK-NEXT: ret i16* [[INTTOPTR]]
-}
-
-define %struct.C* @test44(%struct.C* %c1, %struct.C* %c2) {
- %ptrtoint = ptrtoint %struct.C* %c1 to i64
- %sub = sub i64 0, %ptrtoint
- %shr = sdiv i64 %sub, 7
- %gep = getelementptr inbounds %struct.C* %c2, i64 %shr
- ret %struct.C* %gep
-
-; CHECK-LABEL: @test44(
-; CHECK-NEXT: [[PTRTOINT1:%.*]] = ptrtoint %struct.C* %c1 to i64
-; CHECK-NEXT: [[PTRTOINT2:%.*]] = ptrtoint %struct.C* %c2 to i64
-; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[PTRTOINT2]], [[PTRTOINT1]]
-; CHECK-NEXT: [[INTTOPTR:%.*]] = inttoptr i64 [[SUB]] to %struct.C*
-; CHECK-NEXT: ret %struct.C* [[INTTOPTR]]
-}
-
-define %struct.C* @test45(%struct.C* %c1, %struct.C** %c2) {
- %ptrtoint1 = ptrtoint %struct.C* %c1 to i64
- %ptrtoint2 = ptrtoint %struct.C** %c2 to i64
- %sub = sub i64 %ptrtoint2, %ptrtoint1 ; C2 - C1
- %shr = sdiv i64 %sub, 7
- %gep = getelementptr inbounds %struct.C* %c1, i64 %shr ; C1 + (C2 - C1)
- ret %struct.C* %gep
-
-; CHECK-LABEL: @test45(
-; CHECK-NEXT: [[BITCAST:%.*]] = bitcast %struct.C** %c2 to %struct.C*
-; CHECK-NEXT: ret %struct.C* [[BITCAST]]
-}
-