1 ; RUN: llc -verify-machineinstrs < %s -mcpu=a2q | FileCheck %s
2 target triple = "powerpc64-bgq-linux"
4 @R = global <4 x i1> <i1 0, i1 0, i1 0, i1 0>, align 16
6 define <4 x double> @test1(<4 x double> %a, <4 x double> %b, <4 x i1> %c) nounwind readnone {
8 %r = select <4 x i1> %c, <4 x double> %a, <4 x double> %b
12 ; CHECK: qvfsel 1, 3, 1, 2
16 define <4 x double> @test2(<4 x double> %a, <4 x double> %b, i1 %c1, i1 %c2, i1 %c3, i1 %c4) nounwind readnone {
18 %v = insertelement <4 x i1> undef, i1 %c1, i32 0
19 %v2 = insertelement <4 x i1> %v, i1 %c2, i32 1
20 %v3 = insertelement <4 x i1> %v2, i1 %c3, i32 2
21 %v4 = insertelement <4 x i1> %v3, i1 %c4, i32 3
22 %r = select <4 x i1> %v4, <4 x double> %a, <4 x double> %b
27 ; FIXME: This load/store sequence is unnecessary.
31 ; CHECK-DAG: qvlfiwzx [[REG1:[0-9]+]],
32 ; CHECK-DAG: qvlfdx [[REG2:[0-9]+]],
33 ; CHECK-DAG: qvfcfidu [[REG3:[0-9]+]], [[REG1]]
34 ; CHECK: qvfcmpeq [[REG4:[0-9]+]], [[REG3]], [[REG2]]
35 ; CHECK: qvfsel 1, [[REG4]], 1, 2
39 define <4 x i1> @test3(<4 x i1> %a) nounwind readnone {
41 %v = and <4 x i1> %a, <i1 0, i1 undef, i1 1, i1 1>
45 ; CHECK: qvlfsx [[REG:[0-9]+]],
46 ; qvflogical 1, 1, [[REG]], 1
50 define <4 x i1> @test4(<4 x i1> %a, <4 x i1>* %t) nounwind {
52 %q = load <4 x i1>, <4 x i1>* %t, align 16
53 %v = and <4 x i1> %a, %q
58 ; CHECK-DAG: qvlfdx [[REG1:[0-9]+]],
60 ; CHECK-DAG: qvlfiwzx [[REG2:[0-9]+]],
61 ; CHECK-DAG: qvfcfidu [[REG3:[0-9]+]], [[REG2]]
62 ; CHECK: qvfcmpeq [[REG4:[0-9]+]], [[REG3]], [[REG1]]
63 ; CHECK: qvflogical 1, 1, [[REG4]], 1
67 define void @test5(<4 x i1> %a) nounwind {
69 store <4 x i1> %a, <4 x i1>* @R
73 ; CHECK: qvlfdx [[REG1:[0-9]+]],
74 ; CHECK: qvfmadd [[REG2:[0-9]+]], 1, [[REG1]], [[REG1]]
75 ; CHECK: qvfctiwu [[REG3:[0-9]+]], [[REG2]]
76 ; CHECK: qvstfiwx [[REG3]],
82 define i1 @test6(<4 x i1> %a) nounwind {
84 %r = extractelement <4 x i1> %a, i32 2
88 ; CHECK: qvlfdx [[REG1:[0-9]+]],
89 ; CHECK: qvfmadd [[REG2:[0-9]+]], 1, [[REG1]], [[REG1]]
90 ; CHECK: qvfctiwu [[REG3:[0-9]+]], [[REG2]]
91 ; CHECK: qvstfiwx [[REG3]],
96 define i1 @test7(<4 x i1> %a) nounwind {
98 %r = extractelement <4 x i1> %a, i32 2
99 %s = extractelement <4 x i1> %a, i32 3
103 ; CHECK-LABEL: @test7
104 ; CHECK: qvlfdx [[REG1:[0-9]+]],
105 ; CHECK: qvfmadd [[REG2:[0-9]+]], 1, [[REG1]], [[REG1]]
106 ; CHECK: qvfctiwu [[REG3:[0-9]+]], [[REG2]]
107 ; CHECK: qvstfiwx [[REG3]],
108 ; CHECK-DAG: lwz [[REG4:[0-9]+]],
109 ; FIXME: We're storing the vector twice, and that's silly.
110 ; CHECK-DAG: qvstfiwx [[REG3]],
111 ; CHECK-DAG: lwz [[REG5:[0-9]+]],
116 define i1 @test8(<3 x i1> %a) nounwind {
118 %r = extractelement <3 x i1> %a, i32 2
121 ; CHECK-LABEL: @test8
122 ; CHECK: qvlfdx [[REG1:[0-9]+]],
123 ; CHECK: qvfmadd [[REG2:[0-9]+]], 1, [[REG1]], [[REG1]]
124 ; CHECK: qvfctiwu [[REG3:[0-9]+]], [[REG2]]
125 ; CHECK: qvstfiwx [[REG3]],
130 define <3 x double> @test9(<3 x double> %a, <3 x double> %b, i1 %c1, i1 %c2, i1 %c3) nounwind readnone {
132 %v = insertelement <3 x i1> undef, i1 %c1, i32 0
133 %v2 = insertelement <3 x i1> %v, i1 %c2, i32 1
134 %v3 = insertelement <3 x i1> %v2, i1 %c3, i32 2
135 %r = select <3 x i1> %v3, <3 x double> %a, <3 x double> %b
138 ; CHECK-LABEL: @test9
140 ; FIXME: This load/store sequence is unnecessary.
144 ; CHECK-DAG: qvlfiwzx [[REG1:[0-9]+]],
145 ; CHECK-DAG: qvlfdx [[REG2:[0-9]+]],
146 ; CHECK-DAG: qvfcfidu [[REG3:[0-9]+]], [[REG1]]
147 ; CHECK: qvfcmpeq [[REG4:[0-9]+]], [[REG3]], [[REG2]]
148 ; CHECK: qvfsel 1, [[REG4]], 1, 2