1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S %s -scalarize-masked-mem-intrin -mtriple=x86_64-linux-gnu | FileCheck %s
4 define <2 x i64> @scalarize_v2i64(<2 x i64*> %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: [[PTR0:%.*]] = extractelement <2 x i64*> [[P:%.*]], i64 0
12 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[PTR0]], align 8
13 ; CHECK-NEXT: [[RES0:%.*]] = insertelement <2 x i64> [[PASSTHRU:%.*]], i64 [[LOAD0]], i64 0
14 ; CHECK-NEXT: br label [[ELSE]]
16 ; CHECK-NEXT: [[RES_PHI_ELSE:%.*]] = phi <2 x i64> [ [[RES0]], [[COND_LOAD]] ], [ [[PASSTHRU]], [[TMP0:%.*]] ]
17 ; CHECK-NEXT: [[TMP3:%.*]] = and i2 [[SCALAR_MASK]], -2
18 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ne i2 [[TMP3]], 0
19 ; CHECK-NEXT: br i1 [[TMP4]], label [[COND_LOAD1:%.*]], label [[ELSE2:%.*]]
21 ; CHECK-NEXT: [[PTR1:%.*]] = extractelement <2 x i64*> [[P]], i64 1
22 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[PTR1]], align 8
23 ; CHECK-NEXT: [[RES1:%.*]] = insertelement <2 x i64> [[RES_PHI_ELSE]], i64 [[LOAD1]], i64 1
24 ; CHECK-NEXT: br label [[ELSE2]]
26 ; CHECK-NEXT: [[RES_PHI_ELSE3:%.*]] = phi <2 x i64> [ [[RES1]], [[COND_LOAD1]] ], [ [[RES_PHI_ELSE]], [[ELSE]] ]
27 ; CHECK-NEXT: ret <2 x i64> [[RES_PHI_ELSE3]]
29 %ret = call <2 x i64> @llvm.masked.gather.v2i64.v2p0i64(<2 x i64*> %p, i32 8, <2 x i1> %mask, <2 x i64> %passthru)
33 define <2 x i64> @scalarize_v2i64_ones_mask(<2 x i64*> %p, <2 x i64> %passthru) {
34 ; CHECK-LABEL: @scalarize_v2i64_ones_mask(
35 ; CHECK-NEXT: [[PTR0:%.*]] = extractelement <2 x i64*> [[P:%.*]], i64 0
36 ; CHECK-NEXT: [[LOAD0:%.*]] = load i64, i64* [[PTR0]], align 8
37 ; CHECK-NEXT: [[RES0:%.*]] = insertelement <2 x i64> [[PASSTHRU:%.*]], i64 [[LOAD0]], i64 0
38 ; CHECK-NEXT: [[PTR1:%.*]] = extractelement <2 x i64*> [[P]], i64 1
39 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[PTR1]], align 8
40 ; CHECK-NEXT: [[RES1:%.*]] = insertelement <2 x i64> [[RES0]], i64 [[LOAD1]], i64 1
41 ; CHECK-NEXT: ret <2 x i64> [[RES1]]
43 %ret = call <2 x i64> @llvm.masked.gather.v2i64.v2p0i64(<2 x i64*> %p, i32 8, <2 x i1> <i1 true, i1 true>, <2 x i64> %passthru)
47 define <2 x i64> @scalarize_v2i64_zero_mask(<2 x i64*> %p, <2 x i64> %passthru) {
48 ; CHECK-LABEL: @scalarize_v2i64_zero_mask(
49 ; CHECK-NEXT: ret <2 x i64> [[PASSTHRU:%.*]]
51 %ret = call <2 x i64> @llvm.masked.gather.v2i64.v2p0i64(<2 x i64*> %p, i32 8, <2 x i1> <i1 false, i1 false>, <2 x i64> %passthru)
55 define <2 x i64> @scalarize_v2i64_const_mask(<2 x i64*> %p, <2 x i64> %passthru) {
56 ; CHECK-LABEL: @scalarize_v2i64_const_mask(
57 ; CHECK-NEXT: [[PTR1:%.*]] = extractelement <2 x i64*> [[P:%.*]], i64 1
58 ; CHECK-NEXT: [[LOAD1:%.*]] = load i64, i64* [[PTR1]], align 8
59 ; CHECK-NEXT: [[RES1:%.*]] = insertelement <2 x i64> [[PASSTHRU:%.*]], i64 [[LOAD1]], i64 1
60 ; CHECK-NEXT: ret <2 x i64> [[RES1]]
62 %ret = call <2 x i64> @llvm.masked.gather.v2i64.v2p0i64(<2 x i64*> %p, i32 8, <2 x i1> <i1 false, i1 true>, <2 x i64> %passthru)
66 declare <2 x i64> @llvm.masked.gather.v2i64.v2p0i64(<2 x i64*>, i32, <2 x i1>, <2 x i64>)