This is an archive of the discontinued LLVM Phabricator instance.

[ARM][ReachingDefs] RDA in LoLoops
ClosedPublic

Authored by samparker on Nov 8 2019, 7:08 AM.

Details

Summary

Add several new methods to ReachingDefAnalysis:

  • getReachingMIDef, instead of returning an integer, return the MachineInstr that produces the def.
  • getInstFromId, return a MachineInstr for which the given integer corresponds to.
  • hasSameReachingDef, return whether two MachineInstr use the same def of a register.
  • isRegUsedAfter, return whether a register is used after a given MachineInstr.

These methods have been used in ARMLowOverhead to replace searching for uses/defs.

Diff Detail

Event Timeline

samparker created this revision.Nov 8 2019, 7:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2019, 7:09 AM
dmgreen added inline comments.Nov 10 2019, 2:28 PM
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
139

Can you explain this? Is it valid to just set this property?

samparker marked an inline comment as done.Nov 13 2019, 3:44 AM
samparker added inline comments.
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
139

This pass doesn't change the code so this should be fine. But now I'm thinking that this pass also should require that liveness information is correct on entry.

arsenm added a subscriber: arsenm.Nov 13 2019, 4:12 AM
arsenm added inline comments.
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
139

Yes, this should be setting this in getRequiredProperties

llvm/lib/Target/ARM/ARMInstrThumb2.td
5235 ↗(On Diff #228444)

This is a separate change

dmgreen added inline comments.Nov 13 2019, 4:15 AM
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
139

I thought this was a property, like IsSSA. I'm not very sure either way, but it might not be valid to set that the property holds without checking that it does.

Do you know which pass is causing the property to be removed? Can we fix that to keep it valid?

samparker updated this revision to Diff 229093.Nov 13 2019, 7:14 AM
  • Added liveness tracking as a requirement to RDA, and removed the setting of the property.
  • Removed the CPSR stuff from low-overhead loops, as well as the related test changes.
  • Rewrote the neon test because the liveness information needed to be encoded.
dmgreen added inline comments.Nov 15 2019, 4:40 AM
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
208

You can drop the brackets

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
131

Nit: This needs a clang format.

191–192

"LR can be defined"

218–219

Something like an int is usually not made const, unless it's a reference. But that's just a style preference.

223

Is this one correct? (start as opposed to back)

225

This is getInstId(LRDef)?

451

Does this change need the Defs = [CPSR] for t2LoopDec change? Are there some tests for these cases that didn't change?

llvm/test/CodeGen/Thumb2/ifcvt-neon-deprecated.mir
46

Is this part of the test still important?

samparker marked 3 inline comments as done.Nov 15 2019, 5:49 AM
samparker added inline comments.
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
223

I think I'll make some helpers for these, with more comments, because it's confusing me looking at it again!

225

good point.

451

It didn't need it in the end as this logic allows us to query for a CPSR def inbetween LoopDec (MI) and LoopEnd (back). Again, I'll create a helper which allows us to clearly whether we have a def of something inbetween A and B.

dmgreen added inline comments.Nov 15 2019, 6:04 AM
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
451

And we don't need to check for uses any more?

samparker marked an inline comment as done.Nov 15 2019, 6:22 AM
samparker added inline comments.
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
451

Argh! Indeed we do. And that means there's a hole in my testing.

samparker updated this revision to Diff 229861.Nov 18 2019, 8:55 AM
samparker retitled this revision from [ARM][ReachingDefAnalysis] Use RDA for loloops to [ARM][ReachingDefs] RDA in LoLoops.
samparker edited the summary of this revision. (Show Details)

Taken hasSameReachingDef from D70240 and added isRegUsedAfter to RDA. This allows a great simplication for finding an insertion point and allows us to check for CPSR use/def within the loop too. I've added a couple of extra tests for the CPSR logic.

SjoerdMeijer added inline comments.
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
219

I am a bit confused, this seems to be done in D70240?

I think this all looks OK. Unless Sjoerd/others have further comments. I don't feel like an expert on RDA..

In any case, perhaps leave open for a few days for anyone else to make comments.

llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
128

Lost a / out of ///

llvm/lib/CodeGen/ReachingDefAnalysis.cpp
233

Hmm. You don't know if this is the _same_ PhysReg, right? It could be a different def of the same register?

That would still fit in with how RDA works, but is kind of mixing together liveness and reachability.

Yeah OK. I think this expands reaching defs in a sensible direction.

samparker marked 2 inline comments as done.Nov 21 2019, 7:10 AM
samparker added inline comments.
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
219

Yes, I moved it over and will rebase once that patch is in.

233

True, this doesn't say whether a value is used, just whether a register is live at some point afterwards.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 26 2019, 2:16 AM
This revision was automatically updated to reflect the committed changes.