@@ -486,22 +486,12 @@ bool SDWASrcOperand::convertToSDWA(MachineInstr &MI, const SIInstrInfo *TII) {
486
486
}
487
487
copyRegOperand (*Src, *getTargetOperand ());
488
488
if (!IsPreserveSrc) {
489
- if (SrcSel->getImm () == AMDGPU::SDWA::DWORD) {
490
- // An SDWA instruction with a trivial src_sel, i.e.
491
- // it has either not been adjusted before or it has
492
- // just been created at the call site of this function.
493
- // Use the operand's src_sel.
494
- SrcSel->setImm (getSrcSel ());
495
- }
496
- else {
497
- // A preexisting SDWA instruction with a non-trivial src_sel.
498
- // Combine with the operand src_sel.
499
- std::optional<SdwaSel> NewOp =
500
- combineSdwaSel ((SdwaSel)SrcSel->getImm (), getSrcSel ());
501
- if (!NewOp.has_value ())
502
- return false ;
503
- SrcSel->setImm (NewOp.value ());
504
- }
489
+ SdwaSel ExistingSel = static_cast <SdwaSel>(SrcSel->getImm ());
490
+ std::optional<SdwaSel> NewSel = combineSdwaSel (ExistingSel, getSrcSel ());
491
+ if (!NewSel.has_value ())
492
+ return false ;
493
+ SrcSel->setImm (NewSel.value ());
494
+
505
495
SrcMods->setImm (getSrcMods (TII, Src));
506
496
}
507
497
getTargetOperand ()->setIsKill (false );
@@ -548,15 +538,13 @@ bool SDWADstOperand::convertToSDWA(MachineInstr &MI, const SIInstrInfo *TII) {
548
538
copyRegOperand (*Operand, *getTargetOperand ());
549
539
MachineOperand *DstSel= TII->getNamedOperand (MI, AMDGPU::OpName::dst_sel);
550
540
assert (DstSel);
551
- if (DstSel->getImm () != AMDGPU::SDWA::DWORD) {
552
- std::optional<SdwaSel> NewOp =
553
- combineSdwaSel ((SdwaSel)DstSel->getImm (), getDstSel ());
554
- if (!NewOp.has_value ())
555
- return false ;
556
- DstSel->setImm (NewOp.value ());
557
- } else {
558
- DstSel->setImm (getDstSel ());
559
- }
541
+
542
+ SdwaSel ExistingSel = static_cast <SdwaSel>(DstSel->getImm ());
543
+ std::optional<SdwaSel> NewSel = combineSdwaSel (ExistingSel, getDstSel ());
544
+ if (!NewSel.has_value ())
545
+ return false ;
546
+ DstSel->setImm (NewSel.value ());
547
+
560
548
MachineOperand *DstUnused= TII->getNamedOperand (MI, AMDGPU::OpName::dst_unused);
561
549
assert (DstUnused);
562
550
DstUnused->setImm (getDstUnused ());
0 commit comments