AMDGPU/GlobalISel: Fix non-power-of-2 G_EXTRACT sources

llvm-svn: 358894
This commit is contained in:
Matt Arsenault 2019-04-22 15:22:46 +00:00
parent 75fbd1c604
commit 2b6f76f05f
2 changed files with 57 additions and 1 deletions

View File

@ -561,7 +561,9 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST,
return (LitTy.getScalarSizeInBits() < 16);
},
LegalizeMutations::widenScalarOrEltToNextPow2(LitTyIdx, 16))
.moreElementsIf(isSmallOddVector(BigTyIdx), oneMoreElement(BigTyIdx));
.moreElementsIf(isSmallOddVector(BigTyIdx), oneMoreElement(BigTyIdx))
.widenScalarToNextPow2(BigTyIdx, 32);
}
// TODO: vectors of pointers

View File

@ -29,6 +29,60 @@ body: |
%1:_(s32) = G_EXTRACT %0, 32
$vgpr0 = COPY %1
...
---
name: test_extract_s8_s15_offset0
body: |
bb.0:
liveins: $vgpr0_vgpr1
; CHECK-LABEL: name: test_extract_s8_s15_offset0
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
; CHECK: $vgpr0 = COPY [[TRUNC]](s32)
%0:_(s64) = COPY $vgpr0_vgpr1
%1:_(s31) = G_TRUNC %0
%2:_(s8) = G_EXTRACT %1, 0
%3:_(s32) = G_ANYEXT %2
$vgpr0 = COPY %3
...
---
name: test_extract_s16_s31_offset0
body: |
bb.0:
liveins: $vgpr0_vgpr1
; CHECK-LABEL: name: test_extract_s16_s31_offset0
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
; CHECK: [[EXTRACT:%[0-9]+]]:_(s16) = G_EXTRACT [[TRUNC]](s32), 0
; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[EXTRACT]](s16)
; CHECK: $vgpr0 = COPY [[ANYEXT]](s32)
%0:_(s64) = COPY $vgpr0_vgpr1
%1:_(s31) = G_TRUNC %0
%2:_(s16) = G_EXTRACT %1, 0
%3:_(s32) = G_ANYEXT %2
$vgpr0 = COPY %3
...
---
name: test_extract_s32_s48_offset0
body: |
bb.0:
liveins: $vgpr0_vgpr1
; CHECK-LABEL: name: test_extract_s32_s48_offset0
; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY [[COPY]](s64)
; CHECK: [[EXTRACT:%[0-9]+]]:_(s32) = G_EXTRACT [[COPY1]](s64), 0
; CHECK: $vgpr0 = COPY [[EXTRACT]](s32)
%0:_(s64) = COPY $vgpr0_vgpr1
%1:_(s48) = G_TRUNC %0
%2:_(s32) = G_EXTRACT %1, 0
$vgpr0 = COPY %2
...
---
name: test_extract_s32_s96_offset0
body: |