Skip to content

Commit 321c81f

Browse files
authored
[SWDEV-504914] Correct bitshift legalisation (llvm#2276)
2 parents 73f0152 + 578e1c1 commit 321c81f

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
17651765
// 32-bit amount.
17661766
const LLT ValTy = Query.Types[0];
17671767
const LLT AmountTy = Query.Types[1];
1768-
return ValTy.getSizeInBits() <= 16 &&
1768+
return ValTy.isScalar() && ValTy.getSizeInBits() <= 16 &&
17691769
AmountTy.getSizeInBits() < 16;
17701770
}, changeTo(1, S16));
17711771
Shifts.maxScalarIf(typeIs(0, S16), 1, S16);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; RUN: llc -global-isel -mtriple=amdgcn -mcpu=gfx90a -O0 -print-after=legalizer %s -o /dev/null 2>&1 | FileCheck %s
2+
3+
; CHECK-LABEL: widen_ashr_i4:
4+
define amdgpu_kernel void @widen_ashr_i4(
5+
ptr addrspace(1) %res, i4 %a, i4 %b) {
6+
; CHECK: G_ASHR %{{[0-9]+}}:_, %{{[0-9]+}}:_(s16)
7+
entry:
8+
%res.val = ashr i4 %a, %b
9+
store i4 %res.val, ptr addrspace(1) %res
10+
ret void
11+
}
12+
13+
; CHECK-LABEL: widen_ashr_v4i1:
14+
define amdgpu_kernel void @widen_ashr_v4i1(
15+
ptr addrspace(1) %res, <4 x i1> %a, <4 x i1> %b) {
16+
; CHECK: G_ASHR %{{[0-9]+}}:_, %{{[0-9]+}}:_(s16)
17+
; CHECK: G_ASHR %{{[0-9]+}}:_, %{{[0-9]+}}:_(s16)
18+
; CHECK: G_ASHR %{{[0-9]+}}:_, %{{[0-9]+}}:_(s16)
19+
; CHECK: G_ASHR %{{[0-9]+}}:_, %{{[0-9]+}}:_(s16)
20+
entry:
21+
%res.val = ashr <4 x i1> %a, %b
22+
store <4 x i1> %res.val, ptr addrspace(1) %res
23+
ret void
24+
}

0 commit comments

Comments
 (0)