Index: llvm/include/llvm/CodeGen/GlobalISel/Utils.h =================================================================== --- llvm/include/llvm/CodeGen/GlobalISel/Utils.h +++ llvm/include/llvm/CodeGen/GlobalISel/Utils.h @@ -408,17 +408,6 @@ const MachineRegisterInfo &MRI, bool AllowUndef = false); -/// Return true if the specified instruction is known to be a constant, or a -/// vector of constants. -/// -/// If \p AllowFP is true, this will consider G_FCONSTANT in addition to -/// G_CONSTANT. If \p AllowOpaqueConstants is true, constant-like instructions -/// such as G_GLOBAL_VALUE will also be considered. -bool isConstantOrConstantVector(const MachineInstr &MI, - const MachineRegisterInfo &MRI, - bool AllowFP = true, - bool AllowOpaqueConstants = true); - /// Return true if the value is a constant 0 integer or a splatted vector of a /// constant 0 integer (with no undefs if \p AllowUndefs is false). This will /// handle G_BUILD_VECTOR and G_BUILD_VECTOR TRUNC as truncation is not an issue @@ -454,10 +443,16 @@ Optional getVectorSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI); -/// Determines if \p MI defines a constant integer or a build vector of -/// constant integers. Treats undef values as constants. -bool isConstantOrConstantVector(MachineInstr &MI, - const MachineRegisterInfo &MRI); +/// Return true if the specified instruction is known to be a constant, or a +/// vector of constants. +/// +/// If \p AllowFP is true, this will consider G_FCONSTANT in addition to +/// G_CONSTANT. If \p AllowOpaqueConstants is true, constant-like instructions +/// such as G_GLOBAL_VALUE will also be considered. +bool isConstantOrConstantVector(const MachineInstr &MI, + const MachineRegisterInfo &MRI, + bool AllowFP = true, + bool AllowOpaqueConstants = true); /// Determines if \p MI defines a constant integer or a splat vector of /// constant integers. Index: llvm/lib/CodeGen/GlobalISel/Utils.cpp =================================================================== --- llvm/lib/CodeGen/GlobalISel/Utils.cpp +++ llvm/lib/CodeGen/GlobalISel/Utils.cpp @@ -1125,23 +1125,6 @@ } } -bool llvm::isConstantOrConstantVector(MachineInstr &MI, - const MachineRegisterInfo &MRI) { - Register Def = MI.getOperand(0).getReg(); - if (auto C = getIConstantVRegValWithLookThrough(Def, MRI)) - return true; - GBuildVector *BV = dyn_cast(&MI); - if (!BV) - return false; - for (unsigned SrcIdx = 0; SrcIdx < BV->getNumSources(); ++SrcIdx) { - if (getIConstantVRegValWithLookThrough(BV->getSourceReg(SrcIdx), MRI) || - getOpcodeDef(BV->getSourceReg(SrcIdx), MRI)) - continue; - return false; - } - return true; -} - bool llvm::isConstantOrConstantVector(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowFP, bool AllowOpaqueConstants) {