RFR: 8312213: Remove unnecessary TEST instructions on x86 when flags reg will already be set
Jorn Vernee
jvernee at openjdk.org
Mon Jul 24 13:41:56 UTC 2023
On Fri, 14 Jul 2023 15:09:33 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> I don't think tracking all the nodes that use flags is elegant, you can get the use from the test node, then iterate the operands of the use to find the cmpOp operand which you can know which flag it is using.
Yeah, that sounds better. I think in that case we only need 2 peephole rules, one for `testI_reg` and one for `testL_reg`. In the peep procedure, the rule of the prior instruction can be mapped to the flags that it sets (e.g. a simple `switch` from rule -> mask of flags). Then, if the prior instruction sets all the flags needed by the user of the `test`, we can eliminate the `test` instruction.
In the future, ADL could be extended to allow setting which flags are set or used by an instruction, and then we don't need the ad-hoc mapping of rules -> flags.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14172#issuecomment-1636129101
More information about the hotspot-compiler-dev
mailing list