Skip to content

Commit d98b909

Browse files
[GISel] Add LookThroughInstrs for getIConstantVRegVal and getIConstantVRegSExtVal
The implementation of these methods uses getIConstantVRegValWithLookThrough with LookThroughInstrs argument set to false. By adding the optional argument to getIConstantVRegVal and getIConstantVRegSExtVal we can take advantage of the already built look through functionality.
1 parent 4e9054d commit d98b909

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/CodeGen/GlobalISel/Utils.cpp

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

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

303304
std::optional<int64_t>
304-
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI) {
305+
llvm::getIConstantVRegSExtVal(Register VReg, const MachineRegisterInfo &MRI,
306+
bool LookThroughInstrs = false) {
305307
std::optional<APInt> Val = getIConstantVRegVal(VReg, MRI);
306308
if (Val && Val->getBitWidth() <= 64)
307309
return Val->getSExtValue();

0 commit comments

Comments
 (0)