[PATCH] D119292: GlobalISel: Merge different versions of isConstantOrConstantVector
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 8 14:37:21 PST 2022
arsenm created this revision.
arsenm added reviewers: aemerson, paquette, aditya_nandakumar.
Herald added subscribers: hiraditya, rovka.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
This leans towards the newer version which handles opaque and FP
constants, but does not bother using look through (which seems to
impact no tests).
https://reviews.llvm.org/D119292
Files:
llvm/include/llvm/CodeGen/GlobalISel/Utils.h
llvm/lib/CodeGen/GlobalISel/Utils.cpp
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<GBuildVector>(&MI);
- if (!BV)
- return false;
- for (unsigned SrcIdx = 0; SrcIdx < BV->getNumSources(); ++SrcIdx) {
- if (getIConstantVRegValWithLookThrough(BV->getSourceReg(SrcIdx), MRI) ||
- getOpcodeDef<GImplicitDef>(BV->getSourceReg(SrcIdx), MRI))
- continue;
- return false;
- }
- return true;
-}
-
bool llvm::isConstantOrConstantVector(const MachineInstr &MI,
const MachineRegisterInfo &MRI,
bool AllowFP, bool AllowOpaqueConstants) {
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<RegOrConstant> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119292.406978.patch
Type: text/x-patch
Size: 3286 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220208/8f8a5612/attachment.bin>
More information about the llvm-commits
mailing list