@@ -1160,6 +1160,24 @@ define i64 @test60(ptr %foo, i64 %i, i64 %j) {
11601160 ret i64 %sub
11611161}
11621162
1163+ define i64 @test60_nuw (ptr %foo , i64 %i , i64 %j ) {
1164+ ; CHECK-LABEL: @test60_nuw(
1165+ ; CHECK-NEXT: [[GEP1_IDX:%.*]] = mul nuw i64 [[J:%.*]], 100
1166+ ; CHECK-NEXT: [[GEP1_OFFS:%.*]] = add nuw i64 [[GEP1_IDX]], [[I:%.*]]
1167+ ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr nuw i8, ptr [[FOO:%.*]], i64 [[GEP1_OFFS]]
1168+ ; CHECK-NEXT: [[GEPDIFF:%.*]] = add i64 [[GEP1_OFFS]], -4200
1169+ ; CHECK-NEXT: store ptr [[GEP1]], ptr @dummy_global1, align 8
1170+ ; CHECK-NEXT: ret i64 [[GEPDIFF]]
1171+ ;
1172+ %gep1 = getelementptr nuw [100 x [100 x i8 ]], ptr %foo , i64 0 , i64 %j , i64 %i
1173+ %gep2 = getelementptr nuw [100 x [100 x i8 ]], ptr %foo , i64 0 , i64 42 , i64 0
1174+ %cast1 = ptrtoint ptr %gep1 to i64
1175+ %cast2 = ptrtoint ptr %gep2 to i64
1176+ %sub = sub i64 %cast1 , %cast2
1177+ store ptr %gep1 , ptr @dummy_global1
1178+ ret i64 %sub
1179+ }
1180+
11631181define i64 @test61 (ptr %foo , i64 %i , i64 %j ) {
11641182; CHECK-LABEL: @test61(
11651183; CHECK-NEXT: [[GEP2_IDX:%.*]] = mul nsw i64 [[J:%.*]], 100
0 commit comments