253 lines · plain
1; RUN: llc < %s -mtriple=i386-linux-gnu -o - | FileCheck %s 2 3; This test checks that only a single js gets generated in the final code4; for lowering the CMOV pseudos that get created for this IR.5; CHECK-LABEL: foo1:6; CHECK: js7; CHECK-NOT: js8define i32 @foo1(i32 %v1, i32 %v2, i32 %v3) nounwind {9entry:10 %cmp = icmp slt i32 %v1, 011 %v2.v3 = select i1 %cmp, i32 %v2, i32 %v312 %v1.v2 = select i1 %cmp, i32 %v1, i32 %v213 %sub = sub i32 %v1.v2, %v2.v314 ret i32 %sub15}16 17; This test checks that only a single js gets generated in the final code18; for lowering the CMOV pseudos that get created for this IR. This makes19; sure the code for the lowering for opposite conditions gets tested.20; CHECK-LABEL: foo11:21; CHECK: js22; CHECK-NOT: js23; CHECK-NOT: jns24define i32 @foo11(i32 %v1, i32 %v2, i32 %v3) nounwind {25entry:26 %cmp1 = icmp slt i32 %v1, 027 %v2.v3 = select i1 %cmp1, i32 %v2, i32 %v328 %cmp2 = icmp sge i32 %v1, 029 %v1.v2 = select i1 %cmp2, i32 %v1, i32 %v230 %sub = sub i32 %v1.v2, %v2.v331 ret i32 %sub32}33 34; This test checks that only a single js gets generated in the final code35; for lowering the CMOV pseudos that get created for this IR.36; CHECK-LABEL: foo2:37; CHECK: js38; CHECK-NOT: js39define i32 @foo2(i8 %v1, i8 %v2, i8 %v3) nounwind {40entry:41 %cmp = icmp slt i8 %v1, 042 %v2.v3 = select i1 %cmp, i8 %v2, i8 %v343 %v1.v2 = select i1 %cmp, i8 %v1, i8 %v244 %t1 = sext i8 %v2.v3 to i3245 %t2 = sext i8 %v1.v2 to i3246 %sub = sub i32 %t1, %t247 ret i32 %sub48}49 50; This test checks that only a single js gets generated in the final code51; for lowering the CMOV pseudos that get created for this IR.52; CHECK-LABEL: foo3:53; CHECK: js54; CHECK-NOT: js55define i32 @foo3(i16 %v1, i16 %v2, i16 %v3) nounwind {56entry:57 %cmp = icmp slt i16 %v1, 058 %v2.v3 = select i1 %cmp, i16 %v2, i16 %v359 %v1.v2 = select i1 %cmp, i16 %v1, i16 %v260 %t1 = sext i16 %v2.v3 to i3261 %t2 = sext i16 %v1.v2 to i3262 %sub = sub i32 %t1, %t263 ret i32 %sub64}65 66; This test checks that only a single js gets generated in the final code67; for lowering the CMOV pseudos that get created for this IR.68; CHECK-LABEL: foo4:69; CHECK: js70; CHECK-NOT: js71define float @foo4(i32 %v1, float %v2, float %v3, float %v4) nounwind {72entry:73 %cmp = icmp slt i32 %v1, 074 %t1 = select i1 %cmp, float %v2, float %v375 %t2 = select i1 %cmp, float %v3, float %v476 %sub = fsub float %t1, %t277 ret float %sub78}79 80; This test checks that only a single je gets generated in the final code81; for lowering the CMOV pseudos that get created for this IR.82; CHECK-LABEL: foo5:83; CHECK: je84; CHECK-NOT: je85define double @foo5(i32 %v1, double %v2, double %v3, double %v4) nounwind {86entry:87 %cmp = icmp eq i32 %v1, 088 %t1 = select i1 %cmp, double %v2, double %v389 %t2 = select i1 %cmp, double %v3, double %v490 %sub = fsub double %t1, %t291 ret double %sub92}93 94; This test checks that only a single je gets generated in the final code95; for lowering the CMOV pseudos that get created for this IR.96; CHECK-LABEL: foo6:97; CHECK: je98; CHECK-NOT: je99define <4 x float> @foo6(i32 %v1, <4 x float> %v2, <4 x float> %v3, <4 x float> %v4) nounwind {100entry:101 %cmp = icmp eq i32 %v1, 0102 %t1 = select i1 %cmp, <4 x float> %v2, <4 x float> %v3103 %t2 = select i1 %cmp, <4 x float> %v3, <4 x float> %v4104 %sub = fsub <4 x float> %t1, %t2105 ret <4 x float> %sub106}107 108; This test checks that only a single je gets generated in the final code109; for lowering the CMOV pseudos that get created for this IR.110; CHECK-LABEL: foo7:111; CHECK: je112; CHECK-NOT: je113define <2 x double> @foo7(i32 %v1, <2 x double> %v2, <2 x double> %v3, <2 x double> %v4) nounwind {114entry:115 %cmp = icmp eq i32 %v1, 0116 %t1 = select i1 %cmp, <2 x double> %v2, <2 x double> %v3117 %t2 = select i1 %cmp, <2 x double> %v3, <2 x double> %v4118 %sub = fsub <2 x double> %t1, %t2119 ret <2 x double> %sub120}121 122; This test checks that only a single ja gets generated in the final code123; for lowering the CMOV pseudos that get created for this IR. This combines124; all the supported types together into one long string of selects based125; on the same condition.126; CHECK-LABEL: foo8:127; CHECK: ja128; CHECK-NOT: ja129define void @foo8(i32 %v1,130 i8 %v2, i8 %v3,131 i16 %v12, i16 %v13,132 i32 %v22, i32 %v23,133 float %v32, float %v33,134 double %v42, double %v43,135 <4 x float> %v52, <4 x float> %v53,136 <2 x double> %v62, <2 x double> %v63,137 <8 x float> %v72, <8 x float> %v73,138 <4 x double> %v82, <4 x double> %v83,139 <16 x float> %v92, <16 x float> %v93,140 <8 x double> %v102, <8 x double> %v103,141 ptr %dst) nounwind {142entry:143 %add.ptr11 = getelementptr inbounds i8, ptr %dst, i32 2144 145 %add.ptr21 = getelementptr inbounds i8, ptr %dst, i32 4146 147 %add.ptr31 = getelementptr inbounds i8, ptr %dst, i32 8148 149 %add.ptr41 = getelementptr inbounds i8, ptr %dst, i32 16150 151 %add.ptr51 = getelementptr inbounds i8, ptr %dst, i32 32152 153 %add.ptr61 = getelementptr inbounds i8, ptr %dst, i32 48154 155 %add.ptr71 = getelementptr inbounds i8, ptr %dst, i32 64156 157 %add.ptr81 = getelementptr inbounds i8, ptr %dst, i32 128158 159 %add.ptr91 = getelementptr inbounds i8, ptr %dst, i32 64160 161 %add.ptr101 = getelementptr inbounds i8, ptr %dst, i32 128162 163 ; These operations are necessary, because select of two single use loads164 ; ends up getting optimized into a select of two leas, followed by a165 ; single load of the selected address.166 %t13 = xor i16 %v13, 11167 %t23 = xor i32 %v23, 1234168 %t33 = fadd float %v33, %v32169 %t43 = fadd double %v43, %v42170 %t53 = fadd <4 x float> %v53, %v52171 %t63 = fadd <2 x double> %v63, %v62172 %t73 = fsub <8 x float> %v73, %v72173 %t83 = fsub <4 x double> %v83, %v82174 %t93 = fsub <16 x float> %v93, %v92175 %t103 = fsub <8 x double> %v103, %v102176 177 %cmp = icmp ugt i32 %v1, 31178 %t11 = select i1 %cmp, i16 %v12, i16 %t13179 %t21 = select i1 %cmp, i32 %v22, i32 %t23180 %t31 = select i1 %cmp, float %v32, float %t33181 %t41 = select i1 %cmp, double %v42, double %t43182 %t51 = select i1 %cmp, <4 x float> %v52, <4 x float> %t53183 %t61 = select i1 %cmp, <2 x double> %v62, <2 x double> %t63184 %t71 = select i1 %cmp, <8 x float> %v72, <8 x float> %t73185 %t81 = select i1 %cmp, <4 x double> %v82, <4 x double> %t83186 %t91 = select i1 %cmp, <16 x float> %v92, <16 x float> %t93187 %t101 = select i1 %cmp, <8 x double> %v102, <8 x double> %t103188 189 store i16 %t11, ptr %add.ptr11, align 2190 store i32 %t21, ptr %add.ptr21, align 4191 store float %t31, ptr %add.ptr31, align 4192 store double %t41, ptr %add.ptr41, align 8193 store <4 x float> %t51, ptr %add.ptr51, align 16194 store <2 x double> %t61, ptr %add.ptr61, align 16195 store <8 x float> %t71, ptr %add.ptr71, align 32196 store <4 x double> %t81, ptr %add.ptr81, align 32197 store <16 x float> %t91, ptr %add.ptr91, align 32198 store <8 x double> %t101, ptr %add.ptr101, align 32199 200 ret void201}202 203; This test checks that only a single ja gets generated in the final code204; for lowering the CMOV pseudos that get created for this IR.205; on the same condition.206; Contrary to my expectations, this doesn't exercise the code for207; CMOV_V8I1, CMOV_V16I1, CMOV_V32I1, or CMOV_V64I1. Instead the selects all208; get lowered into vector length number of selects, which all eventually turn209; into a huge number of CMOV_GR8, which are all contiguous, so the optimization210; kicks in as long as CMOV_GR8 is supported. I couldn't find a way to get211; CMOV_V*I1 pseudo-opcodes to get generated. If a way exists to get CMOV_V*1212; pseudo-opcodes to be generated, this test should be replaced with one that213; tests those opcodes.214;215; CHECK-LABEL: foo9:216; CHECK: ja217; CHECK-NOT: ja218define void @foo9(i32 %v1,219 <8 x i1> %v12, <8 x i1> %v13,220 <16 x i1> %v22, <16 x i1> %v23,221 <32 x i1> %v32, <32 x i1> %v33,222 <64 x i1> %v42, <64 x i1> %v43,223 ptr %dst) nounwind {224entry:225 226 %add.ptr21 = getelementptr inbounds i8, ptr %dst, i32 4227 228 %add.ptr31 = getelementptr inbounds i8, ptr %dst, i32 8229 230 %add.ptr41 = getelementptr inbounds i8, ptr %dst, i32 16231 232 ; These operations are necessary, because select of two single use loads233 ; ends up getting optimized into a select of two leas, followed by a234 ; single load of the selected address.235 %t13 = xor <8 x i1> %v13, %v12236 %t23 = xor <16 x i1> %v23, %v22237 %t33 = xor <32 x i1> %v33, %v32238 %t43 = xor <64 x i1> %v43, %v42239 240 %cmp = icmp ugt i32 %v1, 31241 %t11 = select i1 %cmp, <8 x i1> %v12, <8 x i1> %t13242 %t21 = select i1 %cmp, <16 x i1> %v22, <16 x i1> %t23243 %t31 = select i1 %cmp, <32 x i1> %v32, <32 x i1> %t33244 %t41 = select i1 %cmp, <64 x i1> %v42, <64 x i1> %t43245 246 store <8 x i1> %t11, ptr %dst, align 16247 store <16 x i1> %t21, ptr %add.ptr21, align 4248 store <32 x i1> %t31, ptr %add.ptr31, align 8249 store <64 x i1> %t41, ptr %add.ptr41, align 16250 251 ret void252}253