@@ -649,41 +649,25 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
649649 }
650650 }
651651
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) {
656654 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);
660662 }
661663 }
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- }
680664 return false ;
681665 };
682666
683667 // Attempt to find a AVX512 mapping from a full width memory-fold instruction
684668 // to a broadcast-fold instruction variant.
685669 if ((MI.getDesc ().TSFlags & X86II::EncodingMask) == X86II::EVEX)
686- return ConvertToBroadcastAVX512 (Opc, Opc);
670+ return ConvertToBroadcast (Opc, 32 ) || ConvertToBroadcast ( Opc, 64 );
687671
688672 // Reverse the X86InstrInfo::setExecutionDomainCustom EVEX->VEX logic
689673 // conversion to see if we can convert to a broadcasted (integer) logic op.
@@ -740,7 +724,7 @@ bool X86FixupVectorConstantsPass::processInstruction(MachineFunction &MF,
740724 break ;
741725 }
742726 if (OpSrc32 || OpSrc64)
743- return ConvertToBroadcastAVX512 (OpSrc32, OpSrc64);
727+ return ConvertToBroadcast (OpSrc32, 32 ) || ConvertToBroadcast ( OpSrc64, 64 );
744728 }
745729
746730 return false ;
0 commit comments