@@ -852,16 +852,12 @@ define i1 @gep_mugtiple_ugt_inbounds_nusw(ptr %base, i64 %idx, i64 %idx2) {
852852
853853define i1 @gep_multiple_multi_use_below_limit (ptr %base , i64 %idx1 , i64 %idx2 , i64 %idx3 ) {
854854; CHECK-LABEL: @gep_multiple_multi_use_below_limit(
855- ; CHECK-NEXT: [[GEP1_IDX:%.*]] = shl i64 [[IDX1:%.*]], 2
856- ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 [[GEP1_IDX]]
857- ; CHECK-NEXT: [[GEP2_IDX:%.*]] = shl i64 [[IDX2:%.*]], 2
858- ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[GEP1]], i64 [[GEP2_IDX]]
859- ; CHECK-NEXT: [[GEP3_IDX:%.*]] = shl i64 [[IDX3:%.*]], 2
860- ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i8, ptr [[GEP2]], i64 [[GEP3_IDX]]
855+ ; CHECK-NEXT: [[GEP1_IDX1:%.*]] = add i64 [[IDX1:%.*]], [[IDX2:%.*]]
856+ ; CHECK-NEXT: [[IDX3:%.*]] = add i64 [[GEP1_IDX1]], [[IDX4:%.*]]
857+ ; CHECK-NEXT: [[GEP3_IDX:%.*]] = shl i64 [[IDX3]], 2
858+ ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i8, ptr [[GEP2:%.*]], i64 [[GEP3_IDX]]
861859; CHECK-NEXT: call void @use(ptr [[GEP3]])
862- ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[GEP1_IDX]], [[GEP2_IDX]]
863- ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 0, [[GEP3_IDX]]
864- ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP1]], [[TMP2]]
860+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[GEP3_IDX]], 0
865861; CHECK-NEXT: ret i1 [[CMP]]
866862;
867863 %gep1 = getelementptr i32 , ptr %base , i64 %idx1
@@ -874,17 +870,14 @@ define i1 @gep_multiple_multi_use_below_limit(ptr %base, i64 %idx1, i64 %idx2, i
874870
875871define i1 @gep_multiple_multi_use_below_limit_extra_one_use_gep (ptr %base , i64 %idx1 , i64 %idx2 , i64 %idx3 , i64 %idx4 ) {
876872; CHECK-LABEL: @gep_multiple_multi_use_below_limit_extra_one_use_gep(
877- ; CHECK-NEXT: [[GEP1_IDX:%.*]] = shl i64 [[IDX1:%.*]], 2
878- ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 [[GEP1_IDX]]
879- ; CHECK-NEXT: [[GEP2_IDX:%.*]] = shl i64 [[IDX2:%.*]], 2
880- ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[GEP1]], i64 [[GEP2_IDX]]
881- ; CHECK-NEXT: [[GEP3_IDX:%.*]] = shl i64 [[IDX3:%.*]], 2
882- ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i8, ptr [[GEP2]], i64 [[GEP3_IDX]]
883- ; CHECK-NEXT: [[GEP4_IDX_NEG:%.*]] = mul i64 [[IDX4:%.*]], -4
873+ ; CHECK-NEXT: [[GEP1_IDX1:%.*]] = add i64 [[IDX1:%.*]], [[IDX2:%.*]]
874+ ; CHECK-NEXT: [[IDX3:%.*]] = add i64 [[GEP1_IDX1]], [[IDX5:%.*]]
875+ ; CHECK-NEXT: [[GEP3_IDX:%.*]] = shl i64 [[IDX3]], 2
876+ ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i8, ptr [[GEP2:%.*]], i64 [[GEP3_IDX]]
884877; CHECK-NEXT: call void @use(ptr [[GEP3]])
885- ; CHECK-NEXT: [[TMP1 :%.*]] = add i64 [[GEP1_IDX ]], [[GEP2_IDX ]]
886- ; CHECK-NEXT: [[TMP2 :%.*]] = add i64 [[TMP1 ]], [[GEP3_IDX]]
887- ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP2 ]], [[GEP4_IDX_NEG]]
878+ ; CHECK-NEXT: [[TMP3 :%.*]] = add i64 [[IDX3 ]], [[IDX4:%.* ]]
879+ ; CHECK-NEXT: [[DOTMASK :%.*]] = and i64 [[TMP3 ]], 4611686018427387903
880+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[DOTMASK ]], 0
888881; CHECK-NEXT: ret i1 [[CMP]]
889882;
890883 %gep1 = getelementptr i32 , ptr %base , i64 %idx1
@@ -898,16 +891,12 @@ define i1 @gep_multiple_multi_use_below_limit_extra_one_use_gep(ptr %base, i64 %
898891
899892define i1 @gep_multiple_multi_use_below_limit_consts (ptr %base , i64 %idx1 , i64 %idx2 ) {
900893; CHECK-LABEL: @gep_multiple_multi_use_below_limit_consts(
901- ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 16
902- ; CHECK-NEXT: [[GEP2_IDX:%.*]] = shl i64 [[IDX1:%.*]], 2
903- ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i8, ptr [[GEP1]], i64 [[GEP2_IDX]]
904- ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i8, ptr [[GEP2]], i64 16
905- ; CHECK-NEXT: [[GEP4_IDX:%.*]] = shl i64 [[IDX2:%.*]], 2
906- ; CHECK-NEXT: [[GEP4:%.*]] = getelementptr i8, ptr [[GEP3]], i64 [[GEP4_IDX]]
894+ ; CHECK-NEXT: [[IDX2:%.*]] = add i64 [[IDX1:%.*]], [[IDX3:%.*]]
895+ ; CHECK-NEXT: [[GEP4_IDX:%.*]] = shl i64 [[IDX2]], 2
896+ ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[GEP4_IDX]], 32
897+ ; CHECK-NEXT: [[GEP4:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 [[TMP3]]
907898; CHECK-NEXT: call void @use(ptr [[GEP4]])
908- ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[GEP2_IDX]], 32
909- ; CHECK-NEXT: [[TMP2:%.*]] = sub i64 0, [[GEP4_IDX]]
910- ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP1]], [[TMP2]]
899+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP3]], 0
911900; CHECK-NEXT: ret i1 [[CMP]]
912901;
913902 %gep1 = getelementptr i32 , ptr %base , i64 4
@@ -921,12 +910,13 @@ define i1 @gep_multiple_multi_use_below_limit_consts(ptr %base, i64 %idx1, i64 %
921910
922911define i1 @gep_multiple_multi_use_above_limit (ptr %base , i64 %idx1 , i64 %idx2 , i64 %idx3 , i64 %idx4 ) {
923912; CHECK-LABEL: @gep_multiple_multi_use_above_limit(
924- ; CHECK-NEXT: [[GEP1:%.*]] = getelementptr i32, ptr [[BASE:%.*]], i64 [[IDX1:%.*]]
925- ; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i32, ptr [[GEP1]], i64 [[IDX2:%.*]]
926- ; CHECK-NEXT: [[GEP3:%.*]] = getelementptr i32, ptr [[GEP2]], i64 [[IDX3:%.*]]
927- ; CHECK-NEXT: [[GEP4:%.*]] = getelementptr i32, ptr [[GEP3]], i64 [[IDX4:%.*]]
913+ ; CHECK-NEXT: [[GEP1_IDX1:%.*]] = add i64 [[IDX1:%.*]], [[IDX2:%.*]]
914+ ; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[GEP1_IDX1]], [[IDX3:%.*]]
915+ ; CHECK-NEXT: [[TMP2:%.*]] = add i64 [[TMP1]], [[IDX4:%.*]]
916+ ; CHECK-NEXT: [[TMP3:%.*]] = shl i64 [[TMP2]], 2
917+ ; CHECK-NEXT: [[GEP4:%.*]] = getelementptr i8, ptr [[BASE:%.*]], i64 [[TMP3]]
928918; CHECK-NEXT: call void @use(ptr [[GEP4]])
929- ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[GEP4 ]], [[BASE]]
919+ ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[TMP3 ]], 0
930920; CHECK-NEXT: ret i1 [[CMP]]
931921;
932922 %gep1 = getelementptr i32 , ptr %base , i64 %idx1
0 commit comments