2016-01-18 20:02:45 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2013-10-31 21:15:32 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=knl | FileCheck %s
|
|
|
|
|
|
|
|
define <16 x i32> @select00(i32 %a, <16 x i32> %b) nounwind {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select00:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vpxord %zmm1, %zmm1, %zmm1
|
|
|
|
; CHECK-NEXT: cmpl $255, %edi
|
|
|
|
; CHECK-NEXT: je LBB0_2
|
|
|
|
; CHECK-NEXT: ## BB#1:
|
2016-08-01 01:15:07 +08:00
|
|
|
; CHECK-NEXT: vmovdqa64 %zmm0, %zmm1
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: LBB0_2:
|
2016-08-28 14:06:28 +08:00
|
|
|
; CHECK-NEXT: vpxorq %zmm1, %zmm0, %zmm0
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-10-31 21:15:32 +08:00
|
|
|
%cmpres = icmp eq i32 %a, 255
|
|
|
|
%selres = select i1 %cmpres, <16 x i32> zeroinitializer, <16 x i32> %b
|
|
|
|
%res = xor <16 x i32> %b, %selres
|
|
|
|
ret <16 x i32> %res
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x i64> @select01(i32 %a, <8 x i64> %b) nounwind {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select01:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vpxord %zmm1, %zmm1, %zmm1
|
|
|
|
; CHECK-NEXT: cmpl $255, %edi
|
|
|
|
; CHECK-NEXT: je LBB1_2
|
|
|
|
; CHECK-NEXT: ## BB#1:
|
2016-08-01 01:15:07 +08:00
|
|
|
; CHECK-NEXT: vmovdqa64 %zmm0, %zmm1
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: LBB1_2:
|
2016-08-01 01:15:07 +08:00
|
|
|
; CHECK-NEXT: vpxorq %zmm1, %zmm0, %zmm0
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-10-31 21:15:32 +08:00
|
|
|
%cmpres = icmp eq i32 %a, 255
|
|
|
|
%selres = select i1 %cmpres, <8 x i64> zeroinitializer, <8 x i64> %b
|
|
|
|
%res = xor <8 x i64> %b, %selres
|
|
|
|
ret <8 x i64> %res
|
|
|
|
}
|
|
|
|
|
2013-12-16 21:52:35 +08:00
|
|
|
define float @select02(float %a, float %b, float %c, float %eps) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select02:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vcmpless %xmm0, %xmm3, %k1
|
|
|
|
; CHECK-NEXT: vmovss %xmm2, %xmm0, %xmm1 {%k1}
|
2016-09-05 14:43:06 +08:00
|
|
|
; CHECK-NEXT: vmovaps %xmm1, %xmm0
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-12-16 21:52:35 +08:00
|
|
|
%cmp = fcmp oge float %a, %eps
|
|
|
|
%cond = select i1 %cmp, float %c, float %b
|
|
|
|
ret float %cond
|
|
|
|
}
|
|
|
|
|
|
|
|
define double @select03(double %a, double %b, double %c, double %eps) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select03:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vcmplesd %xmm0, %xmm3, %k1
|
|
|
|
; CHECK-NEXT: vmovsd %xmm2, %xmm0, %xmm1 {%k1}
|
2016-09-05 14:43:06 +08:00
|
|
|
; CHECK-NEXT: vmovapd %xmm1, %xmm0
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2013-12-16 21:52:35 +08:00
|
|
|
%cmp = fcmp oge double %a, %eps
|
|
|
|
%cond = select i1 %cmp, double %c, double %b
|
|
|
|
ret double %cond
|
|
|
|
}
|
2014-08-21 21:28:02 +08:00
|
|
|
|
|
|
|
define <16 x double> @select04(<16 x double> %a, <16 x double> %b) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select04:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vmovaps %zmm3, %zmm1
|
|
|
|
; CHECK-NEXT: retq
|
2014-08-21 21:28:02 +08:00
|
|
|
%sel = select <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <16 x double> %a, <16 x double> %b
|
|
|
|
ret <16 x double> %sel
|
|
|
|
}
|
2014-11-01 11:19:45 +08:00
|
|
|
|
|
|
|
define i8 @select05(i8 %a.0, i8 %m) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select05:
|
|
|
|
; CHECK: ## BB#0:
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: orl %esi, %edi
|
2016-05-07 09:11:17 +08:00
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2014-11-01 11:19:45 +08:00
|
|
|
%mask = bitcast i8 %m to <8 x i1>
|
|
|
|
%a = bitcast i8 %a.0 to <8 x i1>
|
|
|
|
%r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
|
|
|
|
%res = bitcast <8 x i1> %r to i8
|
|
|
|
ret i8 %res;
|
|
|
|
}
|
|
|
|
|
2016-04-12 05:10:33 +08:00
|
|
|
define i8 @select05_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
|
|
|
|
; CHECK-LABEL: select05_mem:
|
|
|
|
; CHECK: ## BB#0:
|
2016-06-14 11:13:00 +08:00
|
|
|
; CHECK-NEXT: movzbl (%rsi), %eax
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: kmovw %eax, %k0
|
2016-06-14 11:13:00 +08:00
|
|
|
; CHECK-NEXT: movzbl (%rdi), %eax
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: kmovw %eax, %k1
|
|
|
|
; CHECK-NEXT: korw %k1, %k0, %k0
|
|
|
|
; CHECK-NEXT: kmovw %k0, %eax
|
2017-03-29 00:35:29 +08:00
|
|
|
; CHECK-NEXT: ## kill: %AL<def> %AL<kill> %EAX<kill>
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%mask = load <8 x i1> , <8 x i1>* %m
|
|
|
|
%a = load <8 x i1> , <8 x i1>* %a.0
|
|
|
|
%r = select <8 x i1> %mask, <8 x i1> <i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1, i1 -1>, <8 x i1> %a
|
|
|
|
%res = bitcast <8 x i1> %r to i8
|
|
|
|
ret i8 %res;
|
|
|
|
}
|
|
|
|
|
2014-11-01 11:19:45 +08:00
|
|
|
define i8 @select06(i8 %a.0, i8 %m) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select06:
|
|
|
|
; CHECK: ## BB#0:
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: andl %esi, %edi
|
2016-05-07 09:11:17 +08:00
|
|
|
; CHECK-NEXT: movl %edi, %eax
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2014-11-01 11:19:45 +08:00
|
|
|
%mask = bitcast i8 %m to <8 x i1>
|
|
|
|
%a = bitcast i8 %a.0 to <8 x i1>
|
|
|
|
%r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
|
|
|
|
%res = bitcast <8 x i1> %r to i8
|
|
|
|
ret i8 %res;
|
|
|
|
}
|
|
|
|
|
2016-04-12 05:10:33 +08:00
|
|
|
define i8 @select06_mem(<8 x i1>* %a.0, <8 x i1>* %m) {
|
|
|
|
; CHECK-LABEL: select06_mem:
|
|
|
|
; CHECK: ## BB#0:
|
2016-06-14 11:13:00 +08:00
|
|
|
; CHECK-NEXT: movzbl (%rsi), %eax
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: kmovw %eax, %k0
|
2016-06-14 11:13:00 +08:00
|
|
|
; CHECK-NEXT: movzbl (%rdi), %eax
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: kmovw %eax, %k1
|
|
|
|
; CHECK-NEXT: kandw %k1, %k0, %k0
|
|
|
|
; CHECK-NEXT: kmovw %k0, %eax
|
2017-03-29 00:35:29 +08:00
|
|
|
; CHECK-NEXT: ## kill: %AL<def> %AL<kill> %EAX<kill>
|
2016-04-12 05:10:33 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%mask = load <8 x i1> , <8 x i1>* %m
|
|
|
|
%a = load <8 x i1> , <8 x i1>* %a.0
|
|
|
|
%r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> zeroinitializer
|
|
|
|
%res = bitcast <8 x i1> %r to i8
|
|
|
|
ret i8 %res;
|
|
|
|
}
|
2014-11-01 11:19:45 +08:00
|
|
|
define i8 @select07(i8 %a.0, i8 %b.0, i8 %m) {
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-LABEL: select07:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: kmovw %edx, %k0
|
|
|
|
; CHECK-NEXT: kmovw %edi, %k1
|
|
|
|
; CHECK-NEXT: kmovw %esi, %k2
|
2016-11-03 14:04:28 +08:00
|
|
|
; CHECK-NEXT: kandnw %k2, %k0, %k2
|
|
|
|
; CHECK-NEXT: kandw %k0, %k1, %k0
|
|
|
|
; CHECK-NEXT: korw %k2, %k0, %k0
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: kmovw %k0, %eax
|
2017-03-29 00:35:29 +08:00
|
|
|
; CHECK-NEXT: ## kill: %AL<def> %AL<kill> %EAX<kill>
|
2016-01-18 20:02:45 +08:00
|
|
|
; CHECK-NEXT: retq
|
2014-11-01 11:19:45 +08:00
|
|
|
%mask = bitcast i8 %m to <8 x i1>
|
|
|
|
%a = bitcast i8 %a.0 to <8 x i1>
|
|
|
|
%b = bitcast i8 %b.0 to <8 x i1>
|
|
|
|
%r = select <8 x i1> %mask, <8 x i1> %a, <8 x i1> %b
|
|
|
|
%res = bitcast <8 x i1> %r to i8
|
|
|
|
ret i8 %res;
|
|
|
|
}
|
2016-09-12 23:27:02 +08:00
|
|
|
|
|
|
|
define i64 @pr30249() {
|
|
|
|
; CHECK-LABEL: pr30249:
|
|
|
|
; CHECK: ## BB#0:
|
[DAGCombiner] allow transforming (select Cond, C +/- 1, C) to (add(ext Cond), C)
select Cond, C +/- 1, C --> add(ext Cond), C -- with a target hook.
This is part of the ongoing process to obsolete D24480. The motivation is to
canonicalize to select IR in InstCombine whenever possible, so we need to have a way to
undo that easily in codegen.
PowerPC is an obvious winner for this kind of transform because it has fast and complete
bit-twiddling abilities but generally lousy conditional execution perf (although this might
have changed in recent implementations).
x86 also sees some wins, but the effect is limited because these transforms already mostly
exist in its target-specific combineSelectOfTwoConstants(). The fact that we see any x86
changes just shows that that code is a mess of special-case holes. We may be able to remove
some of that logic now.
My guess is that other targets will want to enable this hook for most cases. The likely
follow-ups would be to add value type and/or the constants themselves as parameters for the
hook. As the tests in select_const.ll show, we can transform any select-of-constants to
math/logic, but the general transform for any 2 constants needs one more instruction
(multiply or 'and').
ARM is one target that I think may not want this for most cases. I see infinite loops there
because it wants to use selects to enable conditionally executed instructions.
Differential Revision: https://reviews.llvm.org/D30537
llvm-svn: 296977
2017-03-05 03:18:09 +08:00
|
|
|
; CHECK-NEXT: movl $2, %eax
|
2016-09-12 23:27:02 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%v = select i1 undef , i64 1, i64 2
|
|
|
|
ret i64 %v
|
|
|
|
}
|
2016-10-06 18:04:00 +08:00
|
|
|
|
2016-10-26 22:12:46 +08:00
|
|
|
define double @pr30561_f64(double %b, double %a, i1 %c) {
|
2016-10-06 18:04:00 +08:00
|
|
|
; CHECK-LABEL: pr30561_f64:
|
|
|
|
; CHECK: ## BB#0:
|
2016-10-26 22:12:46 +08:00
|
|
|
; CHECK-NEXT: andl $1, %edi
|
|
|
|
; CHECK-NEXT: kmovw %edi, %k1
|
|
|
|
; CHECK-NEXT: vmovsd %xmm1, %xmm0, %xmm0 {%k1}
|
2016-10-06 18:04:00 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%cond = select i1 %c, double %a, double %b
|
|
|
|
ret double %cond
|
|
|
|
}
|
|
|
|
|
2016-10-26 22:12:46 +08:00
|
|
|
define float @pr30561_f32(float %b, float %a, i1 %c) {
|
2016-10-06 18:04:00 +08:00
|
|
|
; CHECK-LABEL: pr30561_f32:
|
|
|
|
; CHECK: ## BB#0:
|
2016-10-26 22:12:46 +08:00
|
|
|
; CHECK-NEXT: andl $1, %edi
|
|
|
|
; CHECK-NEXT: kmovw %edi, %k1
|
|
|
|
; CHECK-NEXT: vmovss %xmm1, %xmm0, %xmm0 {%k1}
|
2016-10-06 18:04:00 +08:00
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%cond = select i1 %c, float %a, float %b
|
|
|
|
ret float %cond
|
|
|
|
}
|
2017-01-12 14:49:03 +08:00
|
|
|
|
|
|
|
define <16 x i16> @pr31515(<16 x i1> %a, <16 x i1> %b, <16 x i16> %c) nounwind {
|
|
|
|
; CHECK-LABEL: pr31515:
|
|
|
|
; CHECK: ## BB#0:
|
|
|
|
; CHECK-NEXT: vpmovsxbd %xmm1, %zmm1
|
|
|
|
; CHECK-NEXT: vpslld $31, %zmm1, %zmm1
|
|
|
|
; CHECK-NEXT: vpmovsxbd %xmm0, %zmm0
|
|
|
|
; CHECK-NEXT: vpslld $31, %zmm0, %zmm0
|
|
|
|
; CHECK-NEXT: vptestmd %zmm0, %zmm0, %k1
|
|
|
|
; CHECK-NEXT: vptestmd %zmm1, %zmm1, %k1 {%k1}
|
|
|
|
; CHECK-NEXT: vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z}
|
|
|
|
; CHECK-NEXT: vpmovdw %zmm0, %ymm0
|
|
|
|
; CHECK-NEXT: vpandn %ymm2, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: retq
|
|
|
|
%mask = and <16 x i1> %a, %b
|
|
|
|
%res = select <16 x i1> %mask, <16 x i16> zeroinitializer, <16 x i16> %c
|
|
|
|
ret <16 x i16> %res
|
|
|
|
}
|
|
|
|
|