Revision https://reviews.llvm.org/D122332 added a pattern transformation
where v_cmpx instructions are introduced. However, the modifiers are
not correctly inherited from the original operands. The patch
adds the source modifiers, if they are exist, or sets them to 0.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Looks OK but needs a lit test.
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
454–458 | I'd slightly prefer a "getNamedImmOperandOrZero" which just returns the immediate value, instead of calling Builder.add. | |
456 | Should probably reuse the index that you discarded on the line above, to avoid looking it up by name a second time. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
454–458 | The immediate value should only be added when the operand is found on the instruction, so the builder should only be called with 0 or the immediate value. When just returning the value, it would be required to have additional state which needs to be checked after calling the lambda to ensure a value needs to be added. This would delegate the responsibility back to the caller, but probably complicate everything. I agree with renaming the object though. |
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
454–458 | I refactored this. As getNamedOperand returns nullptr when Idx == -1, the behavior should be the same. |
LGTM, thanks!
llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp | ||
---|---|---|
457 | I think you might be able to simplify this to Builder.add(*Mod) but I'm not sure. |
Should probably reuse the index that you discarded on the line above, to avoid looking it up by name a second time.