Skip to content

Commit 16ddd25

Browse files
committed
Revert "[GISel] Add LookThroughInstrs for getIConstantVRegVal and getIConstan… (#68327)"
This reverts commit 28ae42e. 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.
1 parent 71be514 commit 16ddd25

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

llvm/include/llvm/CodeGen/GlobalISel/Utils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,11 @@ void reportGISelWarning(MachineFunction &MF, const TargetPassConfig &TPC,
171171

172172
/// If \p VReg is defined by a G_CONSTANT, return the corresponding value.
173173
std::optional<APInt> getIConstantVRegVal(Register VReg,
174-
const MachineRegisterInfo &MRI,
175-
bool LookThroughInstrs = false);
174+
const MachineRegisterInfo &MRI);
176175

177176
/// If \p VReg is defined by a G_CONSTANT fits in int64_t returns it.
178177
std::optional<int64_t> getIConstantVRegSExtVal(Register VReg,
179-
const MachineRegisterInfo &MRI,
180-
bool LookThroughInstrs = false);
178+
const MachineRegisterInfo &MRI);
181179

182180
/// Simple struct used to hold a constant integer value and a virtual
183181
/// register.

llvm/lib/CodeGen/GlobalISel/Utils.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,9 @@ void llvm::reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC,
290290
}
291291

292292
std::optional<APInt> llvm::getIConstantVRegVal(Register VReg,
293-
const MachineRegisterInfo &MRI,
294-
bool LookThroughInstrs) {
295-
std::optional<ValueAndVReg> ValAndVReg =
296-
getIConstantVRegValWithLookThrough(VReg, MRI, LookThroughInstrs);
293+
const MachineRegisterInfo &MRI) {
294+
std::optional<ValueAndVReg> ValAndVReg = getIConstantVRegValWithLookThrough(
295+
VReg, MRI, /*LookThroughInstrs*/ false);
297296
assert((!ValAndVReg || ValAndVReg->VReg == VReg) &&
298297
"Value found while looking through instrs");
299298
if (!ValAndVReg)
@@ -302,9 +301,8 @@ std::optional<APInt> llvm::getIConstantVRegVal(Register VReg,
302301
}
303302

304303
std::optional<int64_t>
305-
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI,
306-
bool LookThroughInstrs) {
307-
std::optional<APInt> Val = getIConstantVRegVal(VReg, MRI, LookThroughInstrs);
304+
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI) {
305+
std::optional<APInt> Val = getIConstantVRegVal(VReg, MRI);
308306
if (Val && Val->getBitWidth() <= 64)
309307
return Val->getSExtValue();
310308
return std::nullopt;

llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ static void getICMPOperandsForBranch(MachineInstr &MI, MachineIRBuilder &MIB,
763763
RHS = MI.getOperand(3).getReg();
764764

765765
// Adjust comparisons to use comparison with 0 if possible.
766-
if (auto Constant = getIConstantVRegSExtVal(RHS, MRI, true)) {
766+
if (auto Constant = getIConstantVRegSExtVal(RHS, MRI)) {
767767
switch (ICMPCC) {
768768
case CmpInst::Predicate::ICMP_SGT:
769769
// Convert X > -1 to X >= 0

0 commit comments

Comments
 (0)