Skip to content

Commit 6917799

Browse files
committed
[DirectX backend] change MinVectorRegisterBitWidth to 32.
This is to avoid vector-combine generate vector4 on float. Reviewed By: beanz Differential Revision: https://reviews.llvm.org/D132826
1 parent 13f0795 commit 6917799

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/Target/DirectX/DirectXTargetTransformInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class DirectXTTIImpl : public BasicTTIImplBase<DirectXTTIImpl> {
3333
explicit DirectXTTIImpl(const DirectXTargetMachine *TM, const Function &F)
3434
: BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
3535
TLI(ST->getTargetLowering()) {}
36+
unsigned getMinVectorRegisterBitWidth() const { return 32; }
3637
};
3738
} // namespace llvm
3839

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: opt -S -vector-combine < %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
4+
target triple = "dxil-unknown-shadermodel6.7-library"
5+
6+
; Make sure vec combine min vec size is 1 instead of 4 for float.
7+
; CHECK:@foo()
8+
; CHECK-NEXT:%[[LD:[0-9]+]] = load <1 x float>, ptr @a, align 8
9+
; CHECK-NEXT:%insert = shufflevector <1 x float> %[[LD]], <1 x float> poison, <2 x i32> <i32 0, i32 undef>
10+
; CHECK-NEXT:%shuffle = shufflevector <2 x float> %insert, <2 x float> poison, <2 x i32> zeroinitializer
11+
; CHECK-NEXT:ret <2 x float> %shuffle
12+
13+
@a = external local_unnamed_addr constant float
14+
15+
; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn
16+
define noundef <2 x float> @foo() local_unnamed_addr {
17+
%1 = load float, ptr @a, align 8
18+
%insert = insertelement <2 x float> poison, float %1, i64 0
19+
%shuffle = shufflevector <2 x float> %insert, <2 x float> poison, <2 x i32> zeroinitializer
20+
ret <2 x float> %shuffle
21+
}

0 commit comments

Comments
 (0)