[llvm] r336954 - [X86] Add AVX512 equivalents of some isel patterns so we get EVEX instructions.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 12 15:14:10 PDT 2018
Author: ctopper
Date: Thu Jul 12 15:14:10 2018
New Revision: 336954
URL: http://llvm.org/viewvc/llvm-project?rev=336954&view=rev
Log:
[X86] Add AVX512 equivalents of some isel patterns so we get EVEX instructions.
These are the patterns for matching fceil, ffloor, and sqrt to intrinsic instructions if they have a MOVSS/SD.
Modified:
llvm/trunk/lib/Target/X86/X86InstrAVX512.td
llvm/trunk/lib/Target/X86/X86InstrSSE.td
llvm/trunk/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
llvm/trunk/test/CodeGen/X86/sse-intrinsics-x86-upgrade.ll
llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
Modified: llvm/trunk/lib/Target/X86/X86InstrAVX512.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrAVX512.td?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrAVX512.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrAVX512.td Thu Jul 12 15:14:10 2018
@@ -11484,13 +11484,13 @@ multiclass AVX512_scalar_math_fp_pattern
def : Pat<(_.VT (MoveNode (_.VT VR128X:$dst), (_.VT (scalar_to_vector
(Op (_.EltVT (extractelt (_.VT VR128X:$dst), (iPTR 0))),
_.FRC:$src))))),
- (!cast<I>("V"#OpcPrefix#Zrr_Int) _.VT:$dst,
+ (!cast<Instruction>("V"#OpcPrefix#Zrr_Int) _.VT:$dst,
(COPY_TO_REGCLASS _.FRC:$src, VR128X))>;
// vector math op with insert via movss
def : Pat<(_.VT (MoveNode (_.VT VR128X:$dst),
(Op (_.VT VR128X:$dst), (_.VT VR128X:$src)))),
- (!cast<I>("V"#OpcPrefix#Zrr_Int) _.VT:$dst, _.VT:$src)>;
+ (!cast<Instruction>("V"#OpcPrefix#Zrr_Int) _.VT:$dst, _.VT:$src)>;
// extracted masked scalar math op with insert via movss
def : Pat<(MoveNode (_.VT VR128X:$src1),
@@ -11499,17 +11499,17 @@ multiclass AVX512_scalar_math_fp_pattern
(Op (_.EltVT (extractelt (_.VT VR128X:$src1), (iPTR 0))),
_.FRC:$src2),
_.FRC:$src0))),
- (!cast<I>("V"#OpcPrefix#Zrr_Intk) (COPY_TO_REGCLASS _.FRC:$src0, VR128X),
+ (!cast<Instruction>("V"#OpcPrefix#Zrr_Intk) (COPY_TO_REGCLASS _.FRC:$src0, VR128X),
VK1WM:$mask, _.VT:$src1,
(COPY_TO_REGCLASS _.FRC:$src2, VR128X))>;
-
+
// extracted masked scalar math op with insert via movss
def : Pat<(MoveNode (_.VT VR128X:$src1),
(scalar_to_vector
(X86selects VK1WM:$mask,
(Op (_.EltVT (extractelt (_.VT VR128X:$src1), (iPTR 0))),
_.FRC:$src2), (_.EltVT ZeroFP)))),
- (!cast<I>("V"#OpcPrefix#Zrr_Intkz)
+ (!cast<Instruction>("V"#OpcPrefix#Zrr_Intkz)
VK1WM:$mask, _.VT:$src1,
(COPY_TO_REGCLASS _.FRC:$src2, VR128X))>;
}
@@ -11525,6 +11525,37 @@ defm : AVX512_scalar_math_fp_patterns<fs
defm : AVX512_scalar_math_fp_patterns<fmul, "MULSD", X86Movsd, v2f64x_info, fp64imm0>;
defm : AVX512_scalar_math_fp_patterns<fdiv, "DIVSD", X86Movsd, v2f64x_info, fp64imm0>;
+multiclass AVX512_scalar_unary_math_patterns<SDNode OpNode, string OpcPrefix,
+ SDNode Move, X86VectorVTInfo _> {
+ let Predicates = [HasAVX512] in {
+ def : Pat<(_.VT (Move _.VT:$dst,
+ (scalar_to_vector (OpNode (extractelt _.VT:$src, 0))))),
+ (!cast<Instruction>("V"#OpcPrefix#Zr_Int) _.VT:$dst, _.VT:$src)>;
+ }
+}
+
+defm : AVX512_scalar_unary_math_patterns<fsqrt, "SQRTSS", X86Movss, v4f32x_info>;
+defm : AVX512_scalar_unary_math_patterns<fsqrt, "SQRTSD", X86Movsd, v2f64x_info>;
+
+multiclass AVX512_scalar_unary_math_imm_patterns<SDNode OpNode, string OpcPrefix,
+ SDNode Move, X86VectorVTInfo _,
+ bits<8> ImmV> {
+ let Predicates = [HasAVX512] in {
+ def : Pat<(_.VT (Move _.VT:$dst,
+ (scalar_to_vector (OpNode (extractelt _.VT:$src, 0))))),
+ (!cast<Instruction>("V"#OpcPrefix#Zr_Int) _.VT:$dst, _.VT:$src,
+ (i32 ImmV))>;
+ }
+}
+
+defm : AVX512_scalar_unary_math_imm_patterns<ffloor, "RNDSCALESS", X86Movss,
+ v4f32x_info, 0x01>;
+defm : AVX512_scalar_unary_math_imm_patterns<fceil, "RNDSCALESS", X86Movss,
+ v4f32x_info, 0x02>;
+defm : AVX512_scalar_unary_math_imm_patterns<ffloor, "RNDSCALESD", X86Movsd,
+ v2f64x_info, 0x01>;
+defm : AVX512_scalar_unary_math_imm_patterns<fceil, "RNDSCALESD", X86Movsd,
+ v2f64x_info, 0x02>;
//===----------------------------------------------------------------------===//
// AES instructions
Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Jul 12 15:14:10 2018
@@ -2647,13 +2647,13 @@ multiclass scalar_math_patterns<SDNode O
def : Pat<(VT (Move (VT VR128:$dst), (VT (scalar_to_vector
(Op (EltTy (extractelt (VT VR128:$dst), (iPTR 0))),
RC:$src))))),
- (!cast<I>(OpcPrefix#rr_Int) VT:$dst,
+ (!cast<Instruction>(OpcPrefix#rr_Int) VT:$dst,
(COPY_TO_REGCLASS RC:$src, VR128))>;
// vector math op with insert via movss/movsd
def : Pat<(VT (Move (VT VR128:$dst),
(Op (VT VR128:$dst), (VT VR128:$src)))),
- (!cast<I>(OpcPrefix#rr_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>(OpcPrefix#rr_Int) VT:$dst, VT:$src)>;
}
// Repeat for AVX versions of the instructions.
@@ -2662,13 +2662,13 @@ multiclass scalar_math_patterns<SDNode O
def : Pat<(VT (Move (VT VR128:$dst), (VT (scalar_to_vector
(Op (EltTy (extractelt (VT VR128:$dst), (iPTR 0))),
RC:$src))))),
- (!cast<I>("V"#OpcPrefix#rr_Int) VT:$dst,
+ (!cast<Instruction>("V"#OpcPrefix#rr_Int) VT:$dst,
(COPY_TO_REGCLASS RC:$src, VR128))>;
// vector math op with insert via movss/movsd
def : Pat<(VT (Move (VT VR128:$dst),
(Op (VT VR128:$dst), (VT VR128:$src)))),
- (!cast<I>("V"#OpcPrefix#rr_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>("V"#OpcPrefix#rr_Int) VT:$dst, VT:$src)>;
}
}
@@ -2927,14 +2927,14 @@ multiclass scalar_unary_math_patterns<SD
let Predicates = [BasePredicate] in {
def : Pat<(VT (Move VT:$dst, (scalar_to_vector
(OpNode (extractelt VT:$src, 0))))),
- (!cast<I>(OpcPrefix#r_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>(OpcPrefix#r_Int) VT:$dst, VT:$src)>;
}
// Repeat for AVX versions of the instructions.
- let Predicates = [HasAVX] in {
+ let Predicates = [UseAVX] in {
def : Pat<(VT (Move VT:$dst, (scalar_to_vector
(OpNode (extractelt VT:$src, 0))))),
- (!cast<I>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src)>;
}
}
@@ -2944,14 +2944,14 @@ multiclass scalar_unary_math_imm_pattern
let Predicates = [BasePredicate] in {
def : Pat<(VT (Move VT:$dst, (scalar_to_vector
(OpNode (extractelt VT:$src, 0))))),
- (!cast<Ii8>(OpcPrefix#r_Int) VT:$dst, VT:$src, (i32 ImmV))>;
+ (!cast<Instruction>(OpcPrefix#r_Int) VT:$dst, VT:$src, (i32 ImmV))>;
}
// Repeat for AVX versions of the instructions.
- let Predicates = [HasAVX] in {
+ let Predicates = [UseAVX] in {
def : Pat<(VT (Move VT:$dst, (scalar_to_vector
(OpNode (extractelt VT:$src, 0))))),
- (!cast<Ii8>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src, (i32 ImmV))>;
+ (!cast<Instruction>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src, (i32 ImmV))>;
}
}
@@ -2963,13 +2963,13 @@ multiclass scalar_unary_math_intr_patter
Predicate BasePredicate> {
let Predicates = [BasePredicate] in {
def : Pat<(VT (Move VT:$dst, (Intr VT:$src))),
- (!cast<I>(OpcPrefix#r_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>(OpcPrefix#r_Int) VT:$dst, VT:$src)>;
}
// Repeat for AVX versions of the instructions.
let Predicates = [HasAVX] in {
def : Pat<(VT (Move VT:$dst, (Intr VT:$src))),
- (!cast<I>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src)>;
+ (!cast<Instruction>("V"#OpcPrefix#r_Int) VT:$dst, VT:$src)>;
}
}
Modified: llvm/trunk/test/CodeGen/X86/sse-intrinsics-fast-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-intrinsics-fast-isel.ll?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sse-intrinsics-fast-isel.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sse-intrinsics-fast-isel.ll Thu Jul 12 15:14:10 2018
@@ -2558,10 +2558,15 @@ define <4 x float> @test_mm_sqrt_ss(<4 x
; SSE-NEXT: sqrtss %xmm0, %xmm0 # encoding: [0xf3,0x0f,0x51,0xc0]
; SSE-NEXT: ret{{[l|q]}} # encoding: [0xc3]
;
-; AVX-LABEL: test_mm_sqrt_ss:
-; AVX: # %bb.0:
-; AVX-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 # encoding: [0xc5,0xfa,0x51,0xc0]
-; AVX-NEXT: ret{{[l|q]}} # encoding: [0xc3]
+; AVX1-LABEL: test_mm_sqrt_ss:
+; AVX1: # %bb.0:
+; AVX1-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 # encoding: [0xc5,0xfa,0x51,0xc0]
+; AVX1-NEXT: ret{{[l|q]}} # encoding: [0xc3]
+;
+; AVX512-LABEL: test_mm_sqrt_ss:
+; AVX512: # %bb.0:
+; AVX512-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xfa,0x51,0xc0]
+; AVX512-NEXT: ret{{[l|q]}} # encoding: [0xc3]
%ext = extractelement <4 x float> %a0, i32 0
%sqrt = call float @llvm.sqrt.f32(float %ext)
%ins = insertelement <4 x float> %a0, float %sqrt, i32 0
Modified: llvm/trunk/test/CodeGen/X86/sse-intrinsics-x86-upgrade.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-intrinsics-x86-upgrade.ll?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sse-intrinsics-x86-upgrade.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sse-intrinsics-x86-upgrade.ll Thu Jul 12 15:14:10 2018
@@ -34,10 +34,15 @@ define <4 x float> @test_x86_sse_sqrt_ss
; SSE-NEXT: sqrtss %xmm0, %xmm0 ## encoding: [0xf3,0x0f,0x51,0xc0]
; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
;
-; AVX-LABEL: test_x86_sse_sqrt_ss:
-; AVX: ## %bb.0:
-; AVX-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x51,0xc0]
-; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
+; AVX1-LABEL: test_x86_sse_sqrt_ss:
+; AVX1: ## %bb.0:
+; AVX1-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfa,0x51,0xc0]
+; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
+;
+; AVX512-LABEL: test_x86_sse_sqrt_ss:
+; AVX512: ## %bb.0:
+; AVX512-NEXT: vsqrtss %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfa,0x51,0xc0]
+; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
%res = call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %a0) ; <<4 x float>> [#uses=1]
ret <4 x float> %res
}
Modified: llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll Thu Jul 12 15:14:10 2018
@@ -4896,10 +4896,15 @@ define <2 x double> @test_mm_sqrt_sd(<2
; SSE-NEXT: movapd %xmm1, %xmm0 # encoding: [0x66,0x0f,0x28,0xc1]
; SSE-NEXT: ret{{[l|q]}} # encoding: [0xc3]
;
-; AVX-LABEL: test_mm_sqrt_sd:
-; AVX: # %bb.0:
-; AVX-NEXT: vsqrtsd %xmm0, %xmm1, %xmm0 # encoding: [0xc5,0xf3,0x51,0xc0]
-; AVX-NEXT: ret{{[l|q]}} # encoding: [0xc3]
+; AVX1-LABEL: test_mm_sqrt_sd:
+; AVX1: # %bb.0:
+; AVX1-NEXT: vsqrtsd %xmm0, %xmm1, %xmm0 # encoding: [0xc5,0xf3,0x51,0xc0]
+; AVX1-NEXT: ret{{[l|q]}} # encoding: [0xc3]
+;
+; AVX512-LABEL: test_mm_sqrt_sd:
+; AVX512: # %bb.0:
+; AVX512-NEXT: vsqrtsd %xmm0, %xmm1, %xmm0 # EVEX TO VEX Compression encoding: [0xc5,0xf3,0x51,0xc0]
+; AVX512-NEXT: ret{{[l|q]}} # encoding: [0xc3]
%ext = extractelement <2 x double> %a0, i32 0
%sqrt = call double @llvm.sqrt.f64(double %ext)
%ins = insertelement <2 x double> %a1, double %sqrt, i32 0
Modified: llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll?rev=336954&r1=336953&r2=336954&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sse2-intrinsics-x86-upgrade.ll Thu Jul 12 15:14:10 2018
@@ -34,10 +34,15 @@ define <2 x double> @test_x86_sse2_sqrt_
; SSE-NEXT: sqrtsd %xmm0, %xmm0 ## encoding: [0xf2,0x0f,0x51,0xc0]
; SSE-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
;
-; AVX-LABEL: test_x86_sse2_sqrt_sd:
-; AVX: ## %bb.0:
-; AVX-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfb,0x51,0xc0]
-; AVX-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
+; AVX1-LABEL: test_x86_sse2_sqrt_sd:
+; AVX1: ## %bb.0:
+; AVX1-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfb,0x51,0xc0]
+; AVX1-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
+;
+; AVX512-LABEL: test_x86_sse2_sqrt_sd:
+; AVX512: ## %bb.0:
+; AVX512-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfb,0x51,0xc0]
+; AVX512-NEXT: ret{{[l|q]}} ## encoding: [0xc3]
%res = call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %a0) ; <<2 x double>> [#uses=1]
ret <2 x double> %res
}
@@ -63,7 +68,7 @@ define <2 x double> @test_x86_sse2_sqrt_
; X86-AVX512: ## %bb.0:
; X86-AVX512-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
; X86-AVX512-NEXT: vmovapd (%eax), %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf9,0x28,0x00]
-; X86-AVX512-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfb,0x51,0xc0]
+; X86-AVX512-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfb,0x51,0xc0]
; X86-AVX512-NEXT: retl ## encoding: [0xc3]
;
; X64-SSE-LABEL: test_x86_sse2_sqrt_sd_vec_load:
@@ -81,7 +86,7 @@ define <2 x double> @test_x86_sse2_sqrt_
; X64-AVX512-LABEL: test_x86_sse2_sqrt_sd_vec_load:
; X64-AVX512: ## %bb.0:
; X64-AVX512-NEXT: vmovapd (%rdi), %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xf9,0x28,0x07]
-; X64-AVX512-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## encoding: [0xc5,0xfb,0x51,0xc0]
+; X64-AVX512-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 ## EVEX TO VEX Compression encoding: [0xc5,0xfb,0x51,0xc0]
; X64-AVX512-NEXT: retq ## encoding: [0xc3]
%a1 = load <2 x double>, <2 x double>* %a0, align 16
%res = call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %a1) ; <<2 x double>> [#uses=1]
More information about the llvm-commits
mailing list