Skip to content

Commit 5a59602

Browse files
committed
Eliminate G_TRUNC to S1 SGPR
1 parent 0c48285 commit 5a59602

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegBankLegalize.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,21 @@ bool AMDGPURegBankLegalize::runOnMachineFunction(MachineFunction &MF) {
475475
Combiner.tryCombineCopy(MI);
476476
continue;
477477
}
478+
if (MI.getOpcode() == AMDGPU::G_TRUNC) {
479+
Register Dst = MI.getOperand(0).getReg();
480+
Register Src = MI.getOperand(1).getReg();
481+
auto *SrcDefMI = MRI.getVRegDef(Src);
482+
if (MRI.getType(Dst) != LLT::scalar(1) || !MRI.use_empty(Dst))
483+
continue;
484+
485+
if (SrcDefMI->getOpcode() == AMDGPU::G_UADDO ||
486+
SrcDefMI->getOpcode() == AMDGPU::G_USUBO ||
487+
SrcDefMI->getOpcode() == AMDGPU::G_UADDE ||
488+
SrcDefMI->getOpcode() == AMDGPU::G_USUBE) {
489+
MI.eraseFromParent();
490+
continue;
491+
}
492+
}
478493
if (MI.getOpcode() == AMDGPU::G_ANYEXT) {
479494
Combiner.tryCombineS1AnyExt(MI);
480495
continue;

0 commit comments

Comments
 (0)