@@ -1180,6 +1180,27 @@ define i64 @test61(ptr %foo, i64 %i, i64 %j) {
1180
1180
ret i64 %sub
1181
1181
}
1182
1182
1183
+ declare void @use.ptr (ptr )
1184
+
1185
+ define i64 @test_sub_ptradd_multiuse (ptr %p , i64 %idx1 , i64 %idx2 ) {
1186
+ ; CHECK-LABEL: @test_sub_ptradd_multiuse(
1187
+ ; CHECK-NEXT: [[P1:%.*]] = getelementptr inbounds i8, ptr [[P:%.*]], i64 [[IDX1:%.*]]
1188
+ ; CHECK-NEXT: call void @use.ptr(ptr [[P1]])
1189
+ ; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 [[IDX2:%.*]]
1190
+ ; CHECK-NEXT: [[P1_INT:%.*]] = ptrtoint ptr [[P1]] to i64
1191
+ ; CHECK-NEXT: [[P2_INT:%.*]] = ptrtoint ptr [[P2]] to i64
1192
+ ; CHECK-NEXT: [[SUB:%.*]] = sub i64 [[P1_INT]], [[P2_INT]]
1193
+ ; CHECK-NEXT: ret i64 [[SUB]]
1194
+ ;
1195
+ %p1 = getelementptr inbounds i8 , ptr %p , i64 %idx1
1196
+ call void @use.ptr (ptr %p1 )
1197
+ %p2 = getelementptr inbounds i8 , ptr %p , i64 %idx2
1198
+ %p1.int = ptrtoint ptr %p1 to i64
1199
+ %p2.int = ptrtoint ptr %p2 to i64
1200
+ %sub = sub i64 %p1.int , %p2.int
1201
+ ret i64 %sub
1202
+ }
1203
+
1183
1204
define i32 @test62 (i32 %A ) {
1184
1205
; CHECK-LABEL: @test62(
1185
1206
; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[A:%.*]], 1
0 commit comments