1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S %s -passes=scalarize-masked-mem-intrin -mtriple=x86_64-linux-gnu | FileCheck %s
4 define <2 x i64> @scalarize_v2i64(ptr %p, <2 x i1> %mask, <2 x i64> %passthru) {
5 ; CHECK-LABEL: @scalarize_v2i64(
6 ; CHECK-NEXT: [[SCALAR_MASK:%.*]] = bitcast <2 x i1> [[MASK:%.*]] to i2
7 ; CHECK-NEXT: [[TMP1:%.*]] = and i2 [[SCALAR_MASK]], 1
8 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i2 [[TMP1]], 0
9 ; CHECK-NEXT: br i1 [[TMP2]], label [[COND_LOAD:%.*]], label [[ELSE:%.*]]
11 ; CHECK-NEXT: [[TMP3:%.*]] = load i64, ptr [[P:%.*]], align 1
12 ; CHECK-NEXT: [[TMP4:%.*]] = insertelement <2 x i64> [[PASSTHRU:%.*]], i64 [[TMP3]], i64 0
13 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, ptr [[P]], i32 1
14 ; CHECK-NEXT: br label [[ELSE]]
16 ; CHECK-NEXT: [[RES_PHI_ELSE:%.*]] = phi <2 x i64> [ [[TMP4]], [[COND_LOAD]] ], [ [[PASSTHRU]], [[TMP0:%.*]] ]
17 ; CHECK-NEXT: [[PTR_PHI_ELSE:%.*]] = phi ptr [ [[TMP5]], [[COND_LOAD]] ], [ [[P]], [[TMP0]] ]
18 ; CHECK-NEXT: [[TMP6:%.*]] = and i2 [[SCALAR_MASK]], -2
19 ; CHECK-NEXT: [[TMP7:%.*]] = icmp ne i2 [[TMP6]], 0
20 ; CHECK-NEXT: br i1 [[TMP7]], label [[COND_LOAD1:%.*]], label [[ELSE2:%.*]]
22 ; CHECK-NEXT: [[TMP8:%.*]] = load i64, ptr [[PTR_PHI_ELSE]], align 1
23 ; CHECK-NEXT: [[TMP9:%.*]] = insertelement <2 x i64> [[RES_PHI_ELSE]], i64 [[TMP8]], i64 1
24 ; CHECK-NEXT: br label [[ELSE2]]
26 ; CHECK-NEXT: [[RES_PHI_ELSE3:%.*]] = phi <2 x i64> [ [[TMP9]], [[COND_LOAD1]] ], [ [[RES_PHI_ELSE]], [[ELSE]] ]
27 ; CHECK-NEXT: ret <2 x i64> [[RES_PHI_ELSE3]]
29 %ret = call <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr %p, <2 x i1> %mask, <2 x i64> %passthru)
33 define <2 x i64> @scalarize_v2i64_ones_mask(ptr %p, <2 x i64> %passthru) {
34 ; CHECK-LABEL: @scalarize_v2i64_ones_mask(
35 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i32 0
36 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, ptr [[TMP1]], align 1
37 ; CHECK-NEXT: [[RES0:%.*]] = insertelement <2 x i64> poison, i64 [[LOAD0]], i64 0
38 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i64, ptr [[P]], i32 1
39 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, ptr [[TMP2]], align 1
40 ; CHECK-NEXT: [[RES1:%.*]] = insertelement <2 x i64> [[RES0]], i64 [[LOAD1]], i64 1
41 ; CHECK-NEXT: [[TMP3:%.*]] = shufflevector <2 x i64> [[RES1]], <2 x i64> [[PASSTHRU:%.*]], <2 x i32> <i32 0, i32 1>
42 ; CHECK-NEXT: ret <2 x i64> [[TMP3]]
44 %ret = call <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr %p, <2 x i1> <i1 true, i1 true>, <2 x i64> %passthru)
48 define <2 x i64> @scalarize_v2i64_zero_mask(ptr %p, <2 x i64> %passthru) {
49 ; CHECK-LABEL: @scalarize_v2i64_zero_mask(
50 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <2 x i64> poison, <2 x i64> [[PASSTHRU:%.*]], <2 x i32> <i32 2, i32 3>
51 ; CHECK-NEXT: ret <2 x i64> [[TMP1]]
53 %ret = call <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr %p, <2 x i1> <i1 false, i1 false>, <2 x i64> %passthru)
57 define <2 x i64> @scalarize_v2i64_const_mask(ptr %p, <2 x i64> %passthru) {
58 ; CHECK-LABEL: @scalarize_v2i64_const_mask(
59 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds i64, ptr [[P:%.*]], i32 0
60 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, ptr [[TMP1]], align 1
61 ; CHECK-NEXT: [[RES1:%.*]] = insertelement <2 x i64> poison, i64 [[LOAD1]], i64 1
62 ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <2 x i64> [[RES1]], <2 x i64> [[PASSTHRU:%.*]], <2 x i32> <i32 2, i32 1>
63 ; CHECK-NEXT: ret <2 x i64> [[TMP2]]
65 %ret = call <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr %p, <2 x i1> <i1 false, i1 true>, <2 x i64> %passthru)
69 declare <2 x i64> @llvm.masked.expandload.v2i64.p0(ptr, <2 x i1>, <2 x i64>)