Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,11 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
Op1Info, Op2Info, I);

// Structs etc
if (getTLI()->getValueType(DL, ValTy, true) == MVT::Other)
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy, VecPred, CostKind,
Op1Info, Op2Info, I);

// Selects on vectors are actually vector selects.
if (ISD == ISD::SELECT) {
assert(CondTy && "CondTy must exist");
Expand Down
24 changes: 24 additions & 0 deletions llvm/test/Analysis/CostModel/X86/select.ll
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,27 @@ define <32 x i8> @test_32i8(<32 x i8> %a, <32 x i8> %b) {
ret <32 x i8> %sel
}

define { ptr, ptr } @test_struct( { ptr, ptr } %a, { ptr, ptr } %b, i1 %c) {
; SSE-LABEL: 'test_struct'
; SSE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
; SSE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret { ptr, ptr } %sel
;
; AVX1-LABEL: 'test_struct'
; AVX1-NEXT: Cost Model: Found costs of 1 for: %sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
; AVX1-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret { ptr, ptr } %sel
;
; AVX2-LABEL: 'test_struct'
; AVX2-NEXT: Cost Model: Found costs of 1 for: %sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
; AVX2-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret { ptr, ptr } %sel
;
; AVX512-LABEL: 'test_struct'
; AVX512-NEXT: Cost Model: Found costs of 1 for: %sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
; AVX512-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret { ptr, ptr } %sel
;
; SLM-LABEL: 'test_struct'
; SLM-NEXT: Cost Model: Found costs of 1 for: %sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
; SLM-NEXT: Cost Model: Found costs of RThru:0 CodeSize:1 Lat:1 SizeLat:1 for: ret { ptr, ptr } %sel
;
%sel = select i1 %c, { ptr, ptr } %a, { ptr, ptr } %b
ret { ptr, ptr } %sel
}