Skip to content

Commit d32872e

Browse files
[X86] Stop custom-widening v2f32 = fpext v2bf16
1 parent f2816ff commit d32872e

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32815,10 +32815,11 @@ void X86TargetLowering::ReplaceNodeResults(SDNode *N,
3281532815
// No other ValueType for FP_EXTEND should reach this point.
3281632816
assert(N->getValueType(0) == MVT::v2f32 &&
3281732817
"Do not know how to legalize this Node");
32818-
if (!Subtarget.hasFP16() || !Subtarget.hasVLX())
32819-
return;
3282032818
bool IsStrict = N->isStrictFPOpcode();
3282132819
SDValue Src = N->getOperand(IsStrict ? 1 : 0);
32820+
if (!Subtarget.hasFP16() || !Subtarget.hasVLX() ||
32821+
Src.getValueType().getVectorElementType() != MVT::f16)
32822+
return;
3282232823
SDValue Ext = IsStrict ? DAG.getConstantFP(0.0, dl, MVT::v2f16)
3282332824
: DAG.getUNDEF(MVT::v2f16);
3282432825
SDValue V = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v4f16, Src, Ext);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=x86_64-- -mattr=avx512bf16,avx512fp16 | FileCheck %s
3+
define dso_local void @calc_matrix_tdpbf16ps(<2 x ptr> %ptr) local_unnamed_addr #0 {
4+
; CHECK-LABEL: calc_matrix_tdpbf16ps:
5+
; CHECK: # %bb.0: # %entry
6+
; CHECK-NEXT: xorl %eax, %eax
7+
; CHECK-NEXT: testb %al, %al
8+
; CHECK-NEXT: je .LBB0_1
9+
; CHECK-NEXT: # %bb.2: # %loop.127.preheader
10+
; CHECK-NEXT: retq
11+
; CHECK-NEXT: .LBB0_1: # %ifmerge.89
12+
; CHECK-NEXT: movzwl (%rax), %eax
13+
; CHECK-NEXT: shll $16, %eax
14+
; CHECK-NEXT: vmovd %eax, %xmm0
15+
; CHECK-NEXT: vmulss %xmm0, %xmm0, %xmm0
16+
; CHECK-NEXT: vbroadcastss %xmm0, %xmm0
17+
; CHECK-NEXT: vmovlps %xmm0, (%rax)
18+
entry:
19+
br label %then.13
20+
21+
then.13: ; preds = %entry
22+
%0 = fpext bfloat poison to float
23+
br i1 poison, label %loop.127.preheader, label %ifmerge.89
24+
25+
ifmerge.89: ; preds = %then.13
26+
%.splatinsert144 = insertelement <2 x float> poison, float %0, i64 0
27+
%.splat145 = shufflevector <2 x float> %.splatinsert144, <2 x float> poison, <2 x i32> zeroinitializer
28+
%1 = tail call <2 x bfloat> @llvm.masked.gather.v2bf16.v2p0(<2 x ptr> undef, i32 2, <2 x i1> <i1 true, i1 true>, <2 x bfloat> poison)
29+
%2 = fpext <2 x bfloat> %1 to <2 x float>
30+
%3 = fmul fast <2 x float> %.splat145, %2
31+
%4 = fadd fast <2 x float> zeroinitializer, %3
32+
store <2 x float> %4, ptr poison, align 4
33+
unreachable
34+
35+
loop.127.preheader: ; preds = %then.13
36+
ret void
37+
}
38+
39+
; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)
40+
declare <2 x bfloat> @llvm.masked.gather.v2bf16.v2p0(<2 x ptr>, i32 immarg, <2 x i1>, <2 x bfloat>) #1
41+

0 commit comments

Comments
 (0)