The function only checks that instruction reads a super-register
containing requested physical register. In case if a sub-register
if being read that is also a use of a super-reg, so added the check.
In particular MI->readsRegister() is broken because of the missing
check. The resulting check is essentially regsOverlap().
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I have realized the old check was also needed, an instruction reads a register in both cases: if the operand is a subreg of a requested register or if it is a superreg.
With the new patch previous changes to other targets are gone. Therefor gone the ask to review their test changes.
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | Why is TRI optional here? I would expect it to be mandatory if there is a physical register and assert |
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | That's a good question why, but it is optional. |
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | Here are just some examples of places where the function is called without optional TRI operand and with a physreg: lib/Target/AArch64/AArch64InstrInfo.cpp: 1515│ case AArch64::FCSELDrrr: { lib/Target/AMDGPU/SIInstrInfo.cpp: 4769├> if (MI.findRegisterUseOperandIdx(AMDGPU::SCC) != -1) lib/Target/ARM/ARMLoadStoreOptimizer.cpp: 891├> bool BaseKill = LatestMI->killsRegister(Base); and then: include/llvm/CodeGen/MachineInstr.h: 1134│ bool killsRegister(unsigned Reg, There is huge number of places across all targets. |
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | Altogether 2539 tests fail across all targets if TRI check is removed, even if physreg check is in place. |
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | Is there any real reason not to pass it in though? I would think it shouldn't be hard to make it mandatory, other than the manual work |
lib/CodeGen/MachineInstr.cpp | ||
---|---|---|
936 ↗ | (On Diff #172711) | I do not think there is such a reason. That is just a lot of places across all backends. |
The code change looks fine to me, but it should be possible to cleanup the test case a bit.
test/CodeGen/AMDGPU/optimize-if-exec-masking.mir | ||
---|---|---|
135–151 ↗ | (On Diff #172711) | It should be possible to remove most of the IR here. |
760–781 ↗ | (On Diff #172711) | It should be possible to remove most of this boilerplate. |