Skip to content

Commit 747f67e

Browse files
committed
[AMDGPU] Fix adjustWritemask subreg handling
If we happen to extract a non-dword subreg that breaks the logic of the function and it may shrink the dmask because it does not recognize the use of a lane(s). This bug is next to impossible to trigger with the current lowering in the BE, but it breaks in one of my future patches. Differential Revision: https://reviews.llvm.org/D93782
1 parent be89d74 commit 747f67e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10862,7 +10862,7 @@ SDValue SITargetLowering::PerformDAGCombine(SDNode *N,
1086210862
/// Helper function for adjustWritemask
1086310863
static unsigned SubIdx2Lane(unsigned Idx) {
1086410864
switch (Idx) {
10865-
default: return 0;
10865+
default: return ~0u;
1086610866
case AMDGPU::sub0: return 0;
1086710867
case AMDGPU::sub1: return 1;
1086810868
case AMDGPU::sub2: return 2;
@@ -10922,6 +10922,8 @@ SDNode *SITargetLowering::adjustWritemask(MachineSDNode *&Node,
1092210922
// in OldDmask, so it can be any of X,Y,Z,W; Lane==1 is the second bit
1092310923
// set, etc.
1092410924
Lane = SubIdx2Lane(I->getConstantOperandVal(1));
10925+
if (Lane == ~0u)
10926+
return Node;
1092510927

1092610928
// Check if the use is for the TFE/LWE generated result at VGPRn+1.
1092710929
if (UsesTFC && Lane == TFCLane) {

0 commit comments

Comments
 (0)