This patch removes a bit of code duplication and
moves the v_cmpx optimization out of the
runOnMachineFunction pass.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I would also suggest turning more static functions into const member functions, so you don't have to keep passing around ST and TRI and MRI and TII...
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
86 | Maybe add a new SIRegisterInfo::getEXEC, similar to the existing SIRegisterInfo::getVCC? |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
86 | We talked about that a bit offline. I'm partial to having a "LaneMaskConstants" helper that gives access to a whole suite of wave-size dependent constants, i.e. physical register constants but also for the related opcodes. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 | I don't understand the value of making this a separate class, instead of part of the main SIOptimizeExecMasking class. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 | Even if you do want a separate class there is no need for dynamically creating an instance. You could just have a local variable: SIOptimizeExecMaskingUtils Utils(MF); bool Changed = Utils.optimizeExecSequence(MF); Changed |= Utils.optimizeVCmpxAndSaveexecSequence(MF); |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 | After doing so and adding all necessary members to the SIOptimizeExecMasking class, it felt very cluttered. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 | When you say "the unsafe route" you mean using pointers without adding nullptr checks? That is what I'd prefer, but I'm not going to insist. It looks like you are already doing that for ST in your utils class, which is a pointer with no nullptr checks. If you are determine to keep the utils class I would prefer:
|
Please just merge the two classes. There is no good reason at the moment to separate them.
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 | Sure. Bullet point 3 will not be possible at the moment. TargetSubtargetInfo (which GCNSubtarget subclasses) does not allow copying, and that is required for assignment of reference members as far as I recall. I will merge the class with SIOptimizeExecMasking. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
734 |
You definitely don't want to copy it. Just initialize the reference here: SIOptimizeExecMaskingUtils(MachineFunction &MF) : ST(...) (But this is moot if you're not going to use the utils class.) |
Looks OK to me.
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
24 | I have a slight preference for calling this field "MF" even if it makes runOnMachineFunction a little uglier. |
I have a slight preference for calling this field "MF" even if it makes runOnMachineFunction a little uglier.