Skip to content

Commit f000c4c

Browse files
committed
[VectorCombine] Add tests with multiple noundef indices for scalarization.
1 parent 18225d4 commit f000c4c

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,63 @@ define i32 @load_multiple_extracts_with_variable_indices_large_vector_only_all_v
546546
%res = add i32 %e.0, %e.1
547547
ret i32 %res
548548
}
549+
550+
define i32 @load_multiple_extracts_with_variable_indices_large_vector_only_first_valid_by_and(<16 x i32>* %x, i64 %idx.0, i64 %idx.1) {
551+
; CHECK-LABEL: @load_multiple_extracts_with_variable_indices_large_vector_only_first_valid_by_and(
552+
; CHECK-NEXT: [[IDX_0_CLAMPED:%.*]] = and i64 [[IDX_0:%.*]], 15
553+
; CHECK-NEXT: [[LV:%.*]] = load <16 x i32>, <16 x i32>* [[X:%.*]], align 64
554+
; CHECK-NEXT: [[E_0:%.*]] = extractelement <16 x i32> [[LV]], i64 [[IDX_0_CLAMPED]]
555+
; CHECK-NEXT: [[E_1:%.*]] = extractelement <16 x i32> [[LV]], i64 [[IDX_1:%.*]]
556+
; CHECK-NEXT: [[RES:%.*]] = add i32 [[E_0]], [[E_1]]
557+
; CHECK-NEXT: ret i32 [[RES]]
558+
;
559+
%idx.0.clamped = and i64 %idx.0, 15
560+
561+
%lv = load <16 x i32>, <16 x i32>* %x
562+
%e.0 = extractelement <16 x i32> %lv, i64 %idx.0.clamped
563+
%e.1 = extractelement <16 x i32> %lv, i64 %idx.1
564+
%res = add i32 %e.0, %e.1
565+
ret i32 %res
566+
}
567+
568+
define i32 @load_multiple_extracts_with_variable_indices_large_vector_all_valid_by_and(<16 x i32>* %x, i64 %idx.0, i64 %idx.1) {
569+
; CHECK-LABEL: @load_multiple_extracts_with_variable_indices_large_vector_all_valid_by_and(
570+
; CHECK-NEXT: [[IDX_0_CLAMPED:%.*]] = and i64 [[IDX_0:%.*]], 15
571+
; CHECK-NEXT: [[IDX_1_CLAMPED:%.*]] = and i64 [[IDX_1:%.*]], 15
572+
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <16 x i32>, <16 x i32>* [[X:%.*]], i32 0, i64 [[IDX_0_CLAMPED]]
573+
; CHECK-NEXT: [[E_0:%.*]] = load i32, i32* [[TMP1]], align 4
574+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds <16 x i32>, <16 x i32>* [[X]], i32 0, i64 [[IDX_1_CLAMPED]]
575+
; CHECK-NEXT: [[E_1:%.*]] = load i32, i32* [[TMP2]], align 4
576+
; CHECK-NEXT: [[RES:%.*]] = add i32 [[E_0]], [[E_1]]
577+
; CHECK-NEXT: ret i32 [[RES]]
578+
;
579+
%idx.0.clamped = and i64 %idx.0, 15
580+
%idx.1.clamped = and i64 %idx.1, 15
581+
582+
%lv = load <16 x i32>, <16 x i32>* %x
583+
%e.0 = extractelement <16 x i32> %lv, i64 %idx.0.clamped
584+
%e.1 = extractelement <16 x i32> %lv, i64 %idx.1.clamped
585+
%res = add i32 %e.0, %e.1
586+
ret i32 %res
587+
}
588+
589+
define i32 @load_multiple_extracts_with_variable_indices_large_vector_all_valid_by_and_some_noundef(<16 x i32>* %x, i64 %idx.0, i64 noundef %idx.1) {
590+
; CHECK-LABEL: @load_multiple_extracts_with_variable_indices_large_vector_all_valid_by_and_some_noundef(
591+
; CHECK-NEXT: [[IDX_0_CLAMPED:%.*]] = and i64 [[IDX_0:%.*]], 15
592+
; CHECK-NEXT: [[IDX_1_CLAMPED:%.*]] = and i64 [[IDX_1:%.*]], 15
593+
; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <16 x i32>, <16 x i32>* [[X:%.*]], i32 0, i64 [[IDX_0_CLAMPED]]
594+
; CHECK-NEXT: [[E_0:%.*]] = load i32, i32* [[TMP1]], align 4
595+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds <16 x i32>, <16 x i32>* [[X]], i32 0, i64 [[IDX_1_CLAMPED]]
596+
; CHECK-NEXT: [[E_1:%.*]] = load i32, i32* [[TMP2]], align 4
597+
; CHECK-NEXT: [[RES:%.*]] = add i32 [[E_0]], [[E_1]]
598+
; CHECK-NEXT: ret i32 [[RES]]
599+
;
600+
%idx.0.clamped = and i64 %idx.0, 15
601+
%idx.1.clamped = and i64 %idx.1, 15
602+
603+
%lv = load <16 x i32>, <16 x i32>* %x
604+
%e.0 = extractelement <16 x i32> %lv, i64 %idx.0.clamped
605+
%e.1 = extractelement <16 x i32> %lv, i64 %idx.1.clamped
606+
%res = add i32 %e.0, %e.1
607+
ret i32 %res
608+
}

0 commit comments

Comments
 (0)