@@ -7891,10 +7891,11 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
7891
7891
7892
7892
// Determine the alignment of the load.
7893
7893
Align Alignment;
7894
+ unsigned LoadOpc = LoadMI.getOpcode ();
7894
7895
if (LoadMI.hasOneMemOperand ())
7895
7896
Alignment = (*LoadMI.memoperands_begin ())->getAlign ();
7896
7897
else
7897
- switch (LoadMI. getOpcode () ) {
7898
+ switch (LoadOpc ) {
7898
7899
case X86::AVX512_512_SET0:
7899
7900
case X86::AVX512_512_SETALLONES:
7900
7901
Alignment = Align (64 );
@@ -7958,7 +7959,7 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
7958
7959
return nullptr ;
7959
7960
7960
7961
SmallVector<MachineOperand, X86::AddrNumOperands> MOs;
7961
- switch (LoadMI. getOpcode () ) {
7962
+ switch (LoadOpc ) {
7962
7963
case X86::MMX_SET0:
7963
7964
case X86::V_SET0:
7964
7965
case X86::V_SETALLONES:
@@ -8001,32 +8002,55 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
8001
8002
// Create a constant-pool entry.
8002
8003
MachineConstantPool &MCP = *MF.getConstantPool ();
8003
8004
Type *Ty;
8004
- unsigned Opc = LoadMI.getOpcode ();
8005
- if (Opc == X86::FsFLD0SS || Opc == X86::AVX512_FsFLD0SS)
8005
+ bool IsAllOnes = false ;
8006
+ switch (LoadOpc) {
8007
+ case X86::FsFLD0SS:
8008
+ case X86::AVX512_FsFLD0SS:
8006
8009
Ty = Type::getFloatTy (MF.getFunction ().getContext ());
8007
- else if (Opc == X86::FsFLD0SD || Opc == X86::AVX512_FsFLD0SD)
8010
+ break ;
8011
+ case X86::FsFLD0SD:
8012
+ case X86::AVX512_FsFLD0SD:
8008
8013
Ty = Type::getDoubleTy (MF.getFunction ().getContext ());
8009
- else if (Opc == X86::FsFLD0F128 || Opc == X86::AVX512_FsFLD0F128)
8014
+ break ;
8015
+ case X86::FsFLD0F128:
8016
+ case X86::AVX512_FsFLD0F128:
8010
8017
Ty = Type::getFP128Ty (MF.getFunction ().getContext ());
8011
- else if (Opc == X86::FsFLD0SH || Opc == X86::AVX512_FsFLD0SH)
8018
+ break ;
8019
+ case X86::FsFLD0SH:
8020
+ case X86::AVX512_FsFLD0SH:
8012
8021
Ty = Type::getHalfTy (MF.getFunction ().getContext ());
8013
- else if (Opc == X86::AVX512_512_SET0 || Opc == X86::AVX512_512_SETALLONES)
8022
+ break ;
8023
+ case X86::AVX512_512_SETALLONES:
8024
+ IsAllOnes = true ;
8025
+ [[fallthrough]];
8026
+ case X86::AVX512_512_SET0:
8014
8027
Ty = FixedVectorType::get (Type::getInt32Ty (MF.getFunction ().getContext ()),
8015
8028
16 );
8016
- else if (Opc == X86::AVX2_SETALLONES || Opc == X86::AVX_SET0 ||
8017
- Opc == X86::AVX512_256_SET0 || Opc == X86::AVX1_SETALLONES)
8029
+ break ;
8030
+ case X86::AVX1_SETALLONES:
8031
+ case X86::AVX2_SETALLONES:
8032
+ IsAllOnes = true ;
8033
+ [[fallthrough]];
8034
+ case X86::AVX512_256_SET0:
8035
+ case X86::AVX_SET0:
8018
8036
Ty = FixedVectorType::get (Type::getInt32Ty (MF.getFunction ().getContext ()),
8019
8037
8 );
8020
- else if (Opc == X86::MMX_SET0)
8038
+
8039
+ break ;
8040
+ case X86::MMX_SET0:
8021
8041
Ty = FixedVectorType::get (Type::getInt32Ty (MF.getFunction ().getContext ()),
8022
8042
2 );
8023
- else
8043
+ break ;
8044
+ case X86::V_SETALLONES:
8045
+ IsAllOnes = true ;
8046
+ [[fallthrough]];
8047
+ case X86::V_SET0:
8048
+ case X86::AVX512_128_SET0:
8024
8049
Ty = FixedVectorType::get (Type::getInt32Ty (MF.getFunction ().getContext ()),
8025
8050
4 );
8051
+ break ;
8052
+ }
8026
8053
8027
- bool IsAllOnes =
8028
- (Opc == X86::V_SETALLONES || Opc == X86::AVX2_SETALLONES ||
8029
- Opc == X86::AVX512_512_SETALLONES || Opc == X86::AVX1_SETALLONES);
8030
8054
const Constant *C =
8031
8055
IsAllOnes ? Constant::getAllOnesValue (Ty) : Constant::getNullValue (Ty);
8032
8056
unsigned CPI = MCP.getConstantPoolIndex (C, Alignment);
0 commit comments