RFR: JDK-8213473: Prevent transformation of LoadB->AndI->CmpI pattern to facilitate testb instruction matching

Vladimir Kozlov vladimir.kozlov at oracle.com
Thu Nov 8 02:55:16 UTC 2018

Roman, your change seems fine.

I thought for SPARC it may regress but the only complex rule with AndI+LoadUB I found is for ConvI2L:

match(Set dst (ConvI2L (AndI (LoadUB mem) mask)));

I did not find anything on other platforms.

Anyway it would be nice to run some performance testing.


On 11/7/18 3:46 AM, Roman Kennke wrote:
> In JDK-8203628, Aleksey added matchers to generate testb instruction (on
> x86) for LoadB->AndI->CmpI sequence. However, in AndINode::Ideal() we
> transform any LoadB->AndI to LoadUB->AndI which fails to match this
> pattern. Which means we never actually match for testb. The original
> matchers for LoadUB->AndI->CmpI needed to be removed because of
> JDK-8204479.
> The proposed enhancement would prevent the transformation if we have a
> straight LoadB->AndI->CmpI sequence. While the matcher is x86-only, I
> don't think it actually hurts to prevent this particular sequence. It
> should generate better code (e.g. single testb instructions) for things
> like:
> byte field;
> ..
> if ((field & 3) == 0) ..
> or even:
> if (field == x) .. because we always mask byte loads
> or even (not sure) same for boolean fields.
> Bug:
> https://bugs.openjdk.java.net/browse/JDK-8213473
> Webrev:
> http://cr.openjdk.java.net/~rkennke/JDK-8213473/webrev.00/
> Testing: passes hotspot/jtreg:tier1 here
> Thoughts? Reviews?
> Roman

More information about the hotspot-compiler-dev mailing list