Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Show First 20 Lines • Show All 1,757 Lines • ▼ Show 20 Lines | void CombinerHelper::applyCombineUnmergeMergeToPlainValues( | ||||
LLT SrcTy = MRI.getType(Operands[0]); | LLT SrcTy = MRI.getType(Operands[0]); | ||||
LLT DstTy = MRI.getType(MI.getOperand(0).getReg()); | LLT DstTy = MRI.getType(MI.getOperand(0).getReg()); | ||||
bool CanReuseInputDirectly = DstTy == SrcTy; | bool CanReuseInputDirectly = DstTy == SrcTy; | ||||
Builder.setInstrAndDebugLoc(MI); | Builder.setInstrAndDebugLoc(MI); | ||||
for (unsigned Idx = 0; Idx < NumElems; ++Idx) { | for (unsigned Idx = 0; Idx < NumElems; ++Idx) { | ||||
Register DstReg = MI.getOperand(Idx).getReg(); | Register DstReg = MI.getOperand(Idx).getReg(); | ||||
Register SrcReg = Operands[Idx]; | Register SrcReg = Operands[Idx]; | ||||
// This combine may run after RegBankSelect, so we need to be aware of | |||||
// register banks. | |||||
const auto &DstCB = MRI.getRegClassOrRegBank(DstReg); | |||||
if (!DstCB.isNull() && DstCB != MRI.getRegClassOrRegBank(SrcReg)) { | |||||
SrcReg = Builder.buildCopy(MRI.getType(SrcReg), SrcReg).getReg(0); | |||||
MRI.setRegClassOrRegBank(SrcReg, DstCB); | |||||
} | |||||
arsenm: Should go through one pair of getRegClassOrRegBank calls | |||||
if (CanReuseInputDirectly) | if (CanReuseInputDirectly) | ||||
Not Done ReplyInline ActionsI'm pretty sure we have a helper for this already (at least the artifact combiner handles this already) arsenm: I'm pretty sure we have a helper for this already (at least the artifact combiner handles this… | |||||
Not Done ReplyInline ActionsWhat I was thinking of was canReplaceReg. We should have another flavor that only accepts virtual registers and inserts the copy if needed arsenm: What I was thinking of was canReplaceReg. We should have another flavor that only accepts… | |||||
It's 3 lines now, do we need to create a helper? Pierre-vh: It's 3 lines now, do we need to create a helper?
If yes, what should we name it? Do we just… | |||||
I guess not. However, I’m not sure how scalable this strategy will be as we add more regbank combines. I guess we can go with this for now and see how it works out arsenm: I guess not. However, I’m not sure how scalable this strategy will be as we add more regbank… | |||||
replaceRegWith(MRI, DstReg, SrcReg); | replaceRegWith(MRI, DstReg, SrcReg); | ||||
else | else | ||||
Builder.buildCast(DstReg, SrcReg); | Builder.buildCast(DstReg, SrcReg); | ||||
} | } | ||||
MI.eraseFromParent(); | MI.eraseFromParent(); | ||||
} | } | ||||
bool CombinerHelper::matchCombineUnmergeConstant(MachineInstr &MI, | bool CombinerHelper::matchCombineUnmergeConstant(MachineInstr &MI, | ||||
▲ Show 20 Lines • Show All 4,422 Lines • Show Last 20 Lines |
Should go through one pair of getRegClassOrRegBank calls