@@ -649,41 +649,25 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
649
649
}
650
650
}
651
651
652
- auto ConvertToBroadcastAVX512 = [&](unsigned OpSrc32, unsigned OpSrc64) {
653
- unsigned OpBcst32 = 0 , OpBcst64 = 0 ;
654
- unsigned OpNoBcst32 = 0 , OpNoBcst64 = 0 ;
655
- if (OpSrc32) {
652
+ auto ConvertToBroadcast = [&](unsigned OpSrc, int BW) {
653
+ if (OpSrc) {
656
654
if (const X86FoldTableEntry *Mem2Bcst =
657
- llvm::lookupBroadcastFoldTableBySize (OpSrc32, 32 )) {
658
- OpBcst32 = Mem2Bcst->DstOp ;
659
- OpNoBcst32 = Mem2Bcst->Flags & TB_INDEX_MASK;
655
+ llvm::lookupBroadcastFoldTableBySize (OpSrc, BW)) {
656
+ unsigned OpBcst = Mem2Bcst->DstOp ;
657
+ unsigned OpNoBcst = Mem2Bcst->Flags & TB_INDEX_MASK;
658
+ FixupEntry Fixups[] = {{(int )OpBcst, 1 , BW, rebuildSplatCst}};
659
+ // TODO: Add support for RegBitWidth, but currently rebuildSplatCst
660
+ // doesn't require it (defaults to Constant::getPrimitiveSizeInBits).
661
+ return FixupConstant (Fixups, 0 , OpNoBcst);
660
662
}
661
663
}
662
- if (OpSrc64) {
663
- if (const X86FoldTableEntry *Mem2Bcst =
664
- llvm::lookupBroadcastFoldTableBySize (OpSrc64, 64 )) {
665
- OpBcst64 = Mem2Bcst->DstOp ;
666
- OpNoBcst64 = Mem2Bcst->Flags & TB_INDEX_MASK;
667
- }
668
- }
669
- assert (((OpBcst32 == 0 ) || (OpBcst64 == 0 ) || (OpNoBcst32 == OpNoBcst64)) &&
670
- " OperandNo mismatch" );
671
-
672
- if (OpBcst32 || OpBcst64) {
673
- unsigned OpNo = OpBcst32 == 0 ? OpNoBcst64 : OpNoBcst32;
674
- FixupEntry Fixups[] = {{(int )OpBcst32, 32 , 32 , rebuildSplatCst},
675
- {(int )OpBcst64, 64 , 64 , rebuildSplatCst}};
676
- // TODO: Add support for RegBitWidth, but currently rebuildSplatCst
677
- // doesn't require it (defaults to Constant::getPrimitiveSizeInBits).
678
- return FixupConstant (Fixups, 0 , OpNo);
679
- }
680
664
return false ;
681
665
};
682
666
683
667
// Attempt to find a AVX512 mapping from a full width memory-fold instruction
684
668
// to a broadcast-fold instruction variant.
685
669
if ((MI.getDesc ().TSFlags & X86II::EncodingMask) == X86II::EVEX)
686
- return ConvertToBroadcastAVX512 (Opc, Opc);
670
+ return ConvertToBroadcast (Opc, 32 ) || ConvertToBroadcast ( Opc, 64 );
687
671
688
672
// Reverse the X86InstrInfo::setExecutionDomainCustom EVEX->VEX logic
689
673
// conversion to see if we can convert to a broadcasted (integer) logic op.
@@ -740,7 +724,7 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
740
724
break ;
741
725
}
742
726
if (OpSrc32 || OpSrc64)
743
- return ConvertToBroadcastAVX512 (OpSrc32, OpSrc64);
727
+ return ConvertToBroadcast (OpSrc32, 32 ) || ConvertToBroadcast ( OpSrc64, 64 );
744
728
}
745
729
746
730
return false ;
0 commit comments