Skip to content

Commit 2bf9b9a

Browse files
committed
[TTI] Fix cast cost on vector types.
- Only split vector types when both src and dst types are splittable.
1 parent 1ca85b3 commit 2bf9b9a

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
781781
// cost of the split itself. Count that as 1, to be consistent with
782782
// TLI->getTypeLegalizationCost().
783783
if ((TLI->getTypeAction(Src->getContext(), TLI->getValueType(DL, Src)) ==
784-
TargetLowering::TypeSplitVector) ||
785-
(TLI->getTypeAction(Dst->getContext(), TLI->getValueType(DL, Dst)) ==
786-
TargetLowering::TypeSplitVector)) {
784+
TargetLowering::TypeSplitVector ||
785+
TLI->getTypeAction(Dst->getContext(), TLI->getValueType(DL, Dst)) ==
786+
TargetLowering::TypeSplitVector) &&
787+
Src->getVectorNumElements() > 1 && Dst->getVectorNumElements() > 1) {
787788
Type *SplitDst = VectorType::get(Dst->getVectorElementType(),
788789
Dst->getVectorNumElements() / 2);
789790
Type *SplitSrc = VectorType::get(Src->getVectorElementType(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: opt -licm -mtriple=amdgcn -S -o - %s | FileCheck %s
2+
3+
; CHECK-LABEL: foo
4+
; CHECK: ret
5+
define void @foo(i8* %d, <1 x i32>* %s, i32 %idx) {
6+
entry:
7+
br label %for.body
8+
9+
for.body:
10+
%v0 = load <1 x i32>, <1 x i32>* %s
11+
%v1 = bitcast <1 x i32> %v0 to <4 x i8>
12+
br label %for.cond
13+
14+
for.cond:
15+
%e0 = extractelement <4 x i8> %v1, i32 %idx
16+
store i8 %e0, i8* %d
17+
br i1 false, label %for.exit, label %for.body
18+
19+
for.exit:
20+
ret void
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if not 'AMDGPU' in config.root.targets:
2+
config.unsupported = True

0 commit comments

Comments
 (0)