1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -vector-combine -S %s | FileCheck %s
4 target triple = "arm64-apple-darwin"
6 define void @load_extract_insert_store_const_idx(<225 x double>* %A) {
7 ; CHECK-LABEL: @load_extract_insert_store_const_idx(
9 ; CHECK-NEXT: [[LV:%.*]] = load <225 x double>, <225 x double>* [[A:%.*]], align 8
10 ; CHECK-NEXT: [[EXT_0:%.*]] = extractelement <225 x double> [[LV]], i64 0
11 ; CHECK-NEXT: [[MUL:%.*]] = fmul double 2.000000e+01, [[EXT_0]]
12 ; CHECK-NEXT: [[EXT_1:%.*]] = extractelement <225 x double> [[LV]], i64 1
13 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[EXT_1]], [[MUL]]
14 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <225 x double>, <225 x double>* [[A]], i64 0, i64 1
15 ; CHECK-NEXT: store double [[SUB]], double* [[TMP0]], align 8
16 ; CHECK-NEXT: ret void
19 %lv = load <225 x double>, <225 x double>* %A, align 8
20 %ext.0 = extractelement <225 x double> %lv, i64 0
21 %mul = fmul double 20.0, %ext.0
22 %ext.1 = extractelement <225 x double> %lv, i64 1
23 %sub = fsub double %ext.1, %mul
24 %ins = insertelement <225 x double> %lv, double %sub, i64 1
25 store <225 x double> %ins, <225 x double>* %A, align 8
29 define void @load_extract_insert_store_var_idx_assume_valid(i64 %idx.1, i64 %idx.2, <225 x double>* %A) {
30 ; CHECK-LABEL: @load_extract_insert_store_var_idx_assume_valid(
32 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp ult i64 [[IDX_1:%.*]], 225
33 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP_1]])
34 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ult i64 [[IDX_2:%.*]], 225
35 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP_2]])
36 ; CHECK-NEXT: [[LV:%.*]] = load <225 x double>, <225 x double>* [[A:%.*]], align 8
37 ; CHECK-NEXT: [[EXT_0:%.*]] = extractelement <225 x double> [[LV]], i64 [[IDX_1]]
38 ; CHECK-NEXT: [[MUL:%.*]] = fmul double 2.000000e+01, [[EXT_0]]
39 ; CHECK-NEXT: [[EXT_1:%.*]] = extractelement <225 x double> [[LV]], i64 [[IDX_2]]
40 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[EXT_1]], [[MUL]]
41 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds <225 x double>, <225 x double>* [[A]], i64 0, i64 [[IDX_1]]
42 ; CHECK-NEXT: store double [[SUB]], double* [[TMP0]], align 8
43 ; CHECK-NEXT: ret void
46 %cmp.1 = icmp ult i64 %idx.1, 225
47 call void @llvm.assume(i1 %cmp.1)
48 %cmp.2 = icmp ult i64 %idx.2, 225
49 call void @llvm.assume(i1 %cmp.2)
51 %lv = load <225 x double>, <225 x double>* %A, align 8
52 %ext.0 = extractelement <225 x double> %lv, i64 %idx.1
53 %mul = fmul double 20.0, %ext.0
54 %ext.1 = extractelement <225 x double> %lv, i64 %idx.2
55 %sub = fsub double %ext.1, %mul
56 %ins = insertelement <225 x double> %lv, double %sub, i64 %idx.1
57 store <225 x double> %ins, <225 x double>* %A, align 8
62 define void @load_extract_insert_store_var_idx_no_assume_valid(i64 %idx.1, i64 %idx.2, <225 x double>* %A) {
63 ; CHECK-LABEL: @load_extract_insert_store_var_idx_no_assume_valid(
65 ; CHECK-NEXT: [[LV:%.*]] = load <225 x double>, <225 x double>* [[A:%.*]], align 8
66 ; CHECK-NEXT: [[EXT_0:%.*]] = extractelement <225 x double> [[LV]], i64 [[IDX_1:%.*]]
67 ; CHECK-NEXT: [[MUL:%.*]] = fmul double 2.000000e+01, [[EXT_0]]
68 ; CHECK-NEXT: [[EXT_1:%.*]] = extractelement <225 x double> [[LV]], i64 [[IDX_2:%.*]]
69 ; CHECK-NEXT: [[SUB:%.*]] = fsub double [[EXT_1]], [[MUL]]
70 ; CHECK-NEXT: [[INS:%.*]] = insertelement <225 x double> [[LV]], double [[SUB]], i64 [[IDX_1]]
71 ; CHECK-NEXT: store <225 x double> [[INS]], <225 x double>* [[A]], align 8
72 ; CHECK-NEXT: ret void
75 %lv = load <225 x double>, <225 x double>* %A, align 8
76 %ext.0 = extractelement <225 x double> %lv, i64 %idx.1
77 %mul = fmul double 20.0, %ext.0
78 %ext.1 = extractelement <225 x double> %lv, i64 %idx.2
79 %sub = fsub double %ext.1, %mul
80 %ins = insertelement <225 x double> %lv, double %sub, i64 %idx.1
81 store <225 x double> %ins, <225 x double>* %A, align 8
85 declare void @llvm.assume(i1)