RFR: 8292675: Add identity transformation for removing redundant AndV/OrV nodes

Tobias Hartmann thartmann at openjdk.org
Thu Sep 8 12:02:41 UTC 2022


On Thu, 8 Sep 2022 11:38:49 GMT, Bhavana Kilambi <bkilambi at openjdk.org> wrote:

>> src/hotspot/share/opto/vectornode.cpp line 1907:
>> 
>>> 1905:     // (OperationV src1 (OperationV src1 src2 m1) m1) => OperationV(src1 src2 m1)
>>> 1906:     } else if (n->is_predicated_vector() && n2->is_predicated_vector() &&
>>> 1907:                n->in(3) == n2->in(3) && n->in(1) == n2->in(1)) {
>> 
>> I think this should be merged into line 1902. Why did you omit the `(OperationV src2 (OperationV src1 src2 m1) m1) => OperationV(src1 src2 m1)` case?
>
> Hi, thank you for your review comments. I will make the suggested changes and upload a new patch.
> Regarding omitting this condition - `(OperationV src2 (OperationV src1 src2 m1) m1)` => This would result in a different result as compared to `(OperationV src1 src2 m1)`. So the inner `OperationV` would result in `src1` being copied for unmasked lanes and the outer `OperationV` would result in `src2` being copied to the final result for unmasked lanes and thus the results for both the operations is different. So for masked lanes, the result is `OperationV(src1, src2)` but it is not so for the unmasked lanes. So we need to have the first arguments of both `OperationV` to be same so that the unmasked lanes would then have the same value in the end and that can then be optimized to a single `OperationV` node.

Right, I missed that. Would probably not hurt adding a corresponding comment. Thanks!

-------------

PR: https://git.openjdk.org/jdk/pull/10163


More information about the hotspot-compiler-dev mailing list