Revert "[GISel] Add LookThroughInstrs for getIConstantVRegVal and getIConstan… (#68327)"

This reverts commit 28ae42e6625154dfd164803850b15d8a0c296b94.

The assert in getIConstantVRegVal was not updated for this change.
The ValAndVReg->VReg == VReg check fails if any look through happens.

RISC-V was the only target using the lookthrough functionality, but I'm
not sure it was needed so I'm removing that too.
This commit is contained in:
Craig Topper 2023-11-04 12:14:09 -07:00
parent 71be514fa0
commit 16ddd25b69
3 changed files with 8 additions and 12 deletions

View File

@ -171,13 +171,11 @@ void reportGISelWarning(MachineFunction &MF, const TargetPassConfig &TPC,
/// If \p VReg is defined by a G_CONSTANT, return the corresponding value.
std::optional<APInt> getIConstantVRegVal(Register VReg,
const MachineRegisterInfo &MRI,
bool LookThroughInstrs = false);
const MachineRegisterInfo &MRI);
/// If \p VReg is defined by a G_CONSTANT fits in int64_t returns it.
std::optional<int64_t> getIConstantVRegSExtVal(Register VReg,
const MachineRegisterInfo &MRI,
bool LookThroughInstrs = false);
const MachineRegisterInfo &MRI);
/// Simple struct used to hold a constant integer value and a virtual
/// register.

View File

@ -290,10 +290,9 @@ void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
}
std::optional<APInt> llvm::getIConstantVRegVal(Register VReg,
const MachineRegisterInfo &MRI,
bool LookThroughInstrs) {
std::optional<ValueAndVReg> ValAndVReg =
getIConstantVRegValWithLookThrough(VReg, MRI, LookThroughInstrs);
const MachineRegisterInfo &MRI) {
std::optional<ValueAndVReg> ValAndVReg = getIConstantVRegValWithLookThrough(
VReg, MRI, /*LookThroughInstrs*/ false);
assert((!ValAndVReg || ValAndVReg->VReg == VReg) &&
"Value found while looking through instrs");
if (!ValAndVReg)
@ -302,9 +301,8 @@ std::optional<APInt> llvm::getIConstantVRegVal(Register VReg,
}
std::optional<int64_t>
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI,
bool LookThroughInstrs) {
std::optional<APInt> Val = getIConstantVRegVal(VReg, MRI, LookThroughInstrs);
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI) {
std::optional<APInt> Val = getIConstantVRegVal(VReg, MRI);
if (Val && Val->getBitWidth() <= 64)
return Val->getSExtValue();
return std::nullopt;

View File

@ -763,7 +763,7 @@ static void getICMPOperandsForBranch(MachineInstr &MI, MachineIRBuilder &MIB,
RHS = MI.getOperand(3).getReg();
// Adjust comparisons to use comparison with 0 if possible.
if (auto Constant = getIConstantVRegSExtVal(RHS, MRI, true)) {
if (auto Constant = getIConstantVRegSExtVal(RHS, MRI)) {
switch (ICMPCC) {
case CmpInst::Predicate::ICMP_SGT:
// Convert X > -1 to X >= 0