2016-02-07 06:09:25 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2019-11-06 04:21:29 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-apple-macosx -mattr=+avx2 -enable-no-signed-zeros-fp-math | FileCheck %s
|
2016-02-07 06:09:25 +08:00
|
|
|
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
; Check that the ExeDepsFix pass correctly fixes the domain for broadcast instructions.
|
|
|
|
; <rdar://problem/16354675>
|
|
|
|
|
|
|
|
define <4 x float> @ExeDepsFix_broadcastss(<4 x float> %arg, <4 x float> %arg2) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastss:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vbroadcastss {{.*}}(%rip), %xmm2
|
|
|
|
; CHECK-NEXT: vandps %xmm2, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: vmaxps %xmm1, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <4 x float> %arg to <4 x i32>
|
|
|
|
%and = and <4 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
|
|
|
|
%floatcast = bitcast <4 x i32> %and to <4 x float>
|
|
|
|
%max_is_x = fcmp oge <4 x float> %floatcast, %arg2
|
|
|
|
%max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg2
|
|
|
|
ret <4 x float> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x float> @ExeDepsFix_broadcastss256(<8 x float> %arg, <8 x float> %arg2) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastss256:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vbroadcastss {{.*}}(%rip), %ymm2
|
|
|
|
; CHECK-NEXT: vandps %ymm2, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: vmaxps %ymm1, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <8 x float> %arg to <8 x i32>
|
|
|
|
%and = and <8 x i32> %bitcast, <i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647, i32 2147483647>
|
|
|
|
%floatcast = bitcast <8 x i32> %and to <8 x float>
|
|
|
|
%max_is_x = fcmp oge <8 x float> %floatcast, %arg2
|
|
|
|
%max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg2
|
|
|
|
ret <8 x float> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @ExeDepsFix_broadcastss_inreg(<4 x float> %arg, <4 x float> %arg2, i32 %broadcastvalue) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastss_inreg:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmovd %edi, %xmm2
|
2016-12-07 20:10:49 +08:00
|
|
|
; CHECK-NEXT: vpbroadcastd %xmm2, %xmm2
|
|
|
|
; CHECK-NEXT: vpand %xmm2, %xmm0, %xmm0
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmaxps %xmm1, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <4 x float> %arg to <4 x i32>
|
|
|
|
%in = insertelement <4 x i32> undef, i32 %broadcastvalue, i32 0
|
|
|
|
%mask = shufflevector <4 x i32> %in, <4 x i32> undef, <4 x i32> zeroinitializer
|
|
|
|
%and = and <4 x i32> %bitcast, %mask
|
|
|
|
%floatcast = bitcast <4 x i32> %and to <4 x float>
|
|
|
|
%max_is_x = fcmp oge <4 x float> %floatcast, %arg2
|
|
|
|
%max = select <4 x i1> %max_is_x, <4 x float> %floatcast, <4 x float> %arg2
|
|
|
|
ret <4 x float> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
define <8 x float> @ExeDepsFix_broadcastss256_inreg(<8 x float> %arg, <8 x float> %arg2, i32 %broadcastvalue) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastss256_inreg:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmovd %edi, %xmm2
|
2016-12-07 20:10:49 +08:00
|
|
|
; CHECK-NEXT: vpbroadcastd %xmm2, %ymm2
|
|
|
|
; CHECK-NEXT: vpand %ymm2, %ymm0, %ymm0
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmaxps %ymm1, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <8 x float> %arg to <8 x i32>
|
|
|
|
%in = insertelement <8 x i32> undef, i32 %broadcastvalue, i32 0
|
|
|
|
%mask = shufflevector <8 x i32> %in, <8 x i32> undef, <8 x i32> zeroinitializer
|
|
|
|
%and = and <8 x i32> %bitcast, %mask
|
|
|
|
%floatcast = bitcast <8 x i32> %and to <8 x float>
|
|
|
|
%max_is_x = fcmp oge <8 x float> %floatcast, %arg2
|
|
|
|
%max = select <8 x i1> %max_is_x, <8 x float> %floatcast, <8 x float> %arg2
|
|
|
|
ret <8 x float> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
; In that case the broadcast is directly folded into vandpd.
|
|
|
|
define <2 x double> @ExeDepsFix_broadcastsd(<2 x double> %arg, <2 x double> %arg2) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastsd:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vandpd {{.*}}(%rip), %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: vmaxpd %xmm1, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <2 x double> %arg to <2 x i64>
|
|
|
|
%and = and <2 x i64> %bitcast, <i64 2147483647, i64 2147483647>
|
|
|
|
%floatcast = bitcast <2 x i64> %and to <2 x double>
|
|
|
|
%max_is_x = fcmp oge <2 x double> %floatcast, %arg2
|
|
|
|
%max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg2
|
|
|
|
ret <2 x double> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x double> @ExeDepsFix_broadcastsd256(<4 x double> %arg, <4 x double> %arg2) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastsd256:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vbroadcastsd {{.*}}(%rip), %ymm2
|
|
|
|
; CHECK-NEXT: vandpd %ymm2, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: vmaxpd %ymm1, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <4 x double> %arg to <4 x i64>
|
|
|
|
%and = and <4 x i64> %bitcast, <i64 2147483647, i64 2147483647, i64 2147483647, i64 2147483647>
|
|
|
|
%floatcast = bitcast <4 x i64> %and to <4 x double>
|
|
|
|
%max_is_x = fcmp oge <4 x double> %floatcast, %arg2
|
|
|
|
%max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2
|
|
|
|
ret <4 x double> %max
|
|
|
|
}
|
|
|
|
|
[x86] Teach the target shuffle mask extraction to recognize unary forms
of normally binary shuffle instructions like PUNPCKL and MOVLHPS.
This detects cases where a single register is used for both operands
making the shuffle behave in a unary way. We detect this and adjust the
mask to use the unary form which allows the existing DAG combine for
shuffle instructions to actually work at all.
As a consequence, this uncovered a number of obvious bugs in the
existing DAG combine which are fixed. It also now canonicalizes several
shuffles even with the existing lowering. These typically are trying to
match the shuffle to the domain of the input where before we only really
modeled them with the floating point variants. All of the cases which
change to an integer shuffle here have something in the integer domain, so
there are no more or fewer domain crosses here AFAICT. Technically, it
might be better to go from a GPR directly to the floating point domain,
but detecting floating point *outputs* despite integer inputs is a lot
more code and seems unlikely to be worthwhile in practice. If folks are
seeing domain-crossing regressions here though, let me know and I can
hack something up to fix it.
Also as a consequence, a bunch of missed opportunities to form pshufb
now can be formed. Notably, splats of i8s now form pshufb.
Interestingly, this improves the existing splat lowering too. We go from
3 instructions to 1. Yes, we may tie up a register, but it seems very
likely to be worth it, especially if splatting the 0th byte (the
common case) as then we can use a zeroed register as the mask.
llvm-svn: 214625
2014-08-02 18:27:38 +08:00
|
|
|
; ExeDepsFix works top down, thus it coalesces vpunpcklqdq domain with
|
|
|
|
; vpand and there is nothing more you can do to match vmaxpd.
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
define <2 x double> @ExeDepsFix_broadcastsd_inreg(<2 x double> %arg, <2 x double> %arg2, i64 %broadcastvalue) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastsd_inreg:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmovq %rdi, %xmm2
|
|
|
|
; CHECK-NEXT: vpbroadcastq %xmm2, %xmm2
|
|
|
|
; CHECK-NEXT: vpand %xmm2, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: vmaxpd %xmm1, %xmm0, %xmm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <2 x double> %arg to <2 x i64>
|
|
|
|
%in = insertelement <2 x i64> undef, i64 %broadcastvalue, i32 0
|
|
|
|
%mask = shufflevector <2 x i64> %in, <2 x i64> undef, <2 x i32> zeroinitializer
|
|
|
|
%and = and <2 x i64> %bitcast, %mask
|
|
|
|
%floatcast = bitcast <2 x i64> %and to <2 x double>
|
|
|
|
%max_is_x = fcmp oge <2 x double> %floatcast, %arg2
|
|
|
|
%max = select <2 x i1> %max_is_x, <2 x double> %floatcast, <2 x double> %arg2
|
|
|
|
ret <2 x double> %max
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x double> @ExeDepsFix_broadcastsd256_inreg(<4 x double> %arg, <4 x double> %arg2, i64 %broadcastvalue) {
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-LABEL: ExeDepsFix_broadcastsd256_inreg:
|
2017-12-05 01:18:51 +08:00
|
|
|
; CHECK: ## %bb.0:
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmovq %rdi, %xmm2
|
2016-12-07 20:10:49 +08:00
|
|
|
; CHECK-NEXT: vpbroadcastq %xmm2, %ymm2
|
|
|
|
; CHECK-NEXT: vpand %ymm2, %ymm0, %ymm0
|
2016-02-07 06:09:25 +08:00
|
|
|
; CHECK-NEXT: vmaxpd %ymm1, %ymm0, %ymm0
|
|
|
|
; CHECK-NEXT: retq
|
[X86] Add broadcast instructions to the table used by ExeDepsFix pass.
Adds the different broadcast instructions to the ReplaceableInstrsAVX2 table.
That way the ExeDepsFix pass can take better decisions when AVX2 broadcasts are
across domain (int <-> float).
In particular, prior to this patch we were generating:
vpbroadcastd LCPI1_0(%rip), %ymm2
vpand %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0 ## <- domain change penalty
Now, we generate the following nice sequence where everything is in the float
domain:
vbroadcastss LCPI1_0(%rip), %ymm2
vandps %ymm2, %ymm0, %ymm0
vmaxps %ymm1, %ymm0, %ymm0
<rdar://problem/16354675>
llvm-svn: 204770
2014-03-26 08:10:22 +08:00
|
|
|
%bitcast = bitcast <4 x double> %arg to <4 x i64>
|
|
|
|
%in = insertelement <4 x i64> undef, i64 %broadcastvalue, i32 0
|
|
|
|
%mask = shufflevector <4 x i64> %in, <4 x i64> undef, <4 x i32> zeroinitializer
|
|
|
|
%and = and <4 x i64> %bitcast, %mask
|
|
|
|
%floatcast = bitcast <4 x i64> %and to <4 x double>
|
|
|
|
%max_is_x = fcmp oge <4 x double> %floatcast, %arg2
|
|
|
|
%max = select <4 x i1> %max_is_x, <4 x double> %floatcast, <4 x double> %arg2
|
|
|
|
ret <4 x double> %max
|
|
|
|
}
|