[aarch64-port-dev ] RFR 8248870: AARCH64: I2L conversions can be skipped for small positive masked values
Eric Liu
eric.c.liu at arm.com
Mon Jul 27 14:35:17 UTC 2020
Hi,
We are planing to elide the redundant 'sxt' on AArch64 in macro-assembler for better performance and small code size. I think the
redundant signed extend could be generated in following cases:
A) Load a data less than 32 bits and then using it as 64 bits data. E.g.
ldrsb w1, mem
sxt x1, w1
B) And with a possible number. E.g.
and w11, w1, #0xffff
sxtw x0, w11
C) Sign extend a number twice. E.g.
sxth w11, w1
sxtw x0, w11
To address issue A), current C2's ad file has about 8 match rules to match those kinds of patterns. E.g.
// Load Byte (8 bit signed) into long
instruct loadB2L(iRegLNoSp dst, memory1 mem)
%{
match(Set dst (ConvI2L (LoadB mem)));
predicate(!needs_acquiring_load(n->in(1)));
ins_cost(4 * INSN_COST);
format %{ "ldrsb $dst, $mem\t# byte" %}
ins_encode(aarch64_enc_ldrsb(dst, mem));
ins_pipe(iload_reg_mem);
%}
For issue B), Boris' patch did a good job to elide the redundant 'sxt' followed by 'and'. But this pair could also be generated
by other pattern, e.g. (ConvI2L (RShiftI (LShiftI src lshift_count) rshift_count)). This pattern can be reproduced by below case:
public static long l2c2l (long x) {
return (char) x;
}
For issue C), type conversion usually generate those piece of code. e.g.
private static long test_l2s2l(long x) {
return (short) x;
}
In my view, eliding the redundant 'sxt' above are more likely a machine code problem rather than a IR problem.
I think peephole is the best fit for above optimization. However, C2's peephole is very complicated and I'm not
sure whether it has been enabled in AArch64.
So I was thinking if it better to remove this kinds of instructions in macro-assembler, even this sounds somehow beyond
the assembler's responsibility. By handling those pair in macro-assembler, we can only focus on instruction sequence rather
than the type and shape of IR node.
What do you think? Welcome any feedback!
--
Best regards,
Eric
From: hotspot-compiler-dev <hotspot-compiler-dev-retn at openjdk.java.net> on behalf of Andrew Haley <aph at redhat.com>
Sent: 24 July 2020 16:18
To: Boris Ulasevich <boris.ulasevich at bell-sw.com>; aarch64-port-dev at openjdk.java.net <aarch64-port-dev at openjdk.java.net>
Cc: hotspot-compiler-dev at openjdk.java.net <hotspot-compiler-dev at openjdk.java.net>
Subject: Re: [aarch64-port-dev ] RFR 8248870: AARCH64: I2L conversions can be skipped for small positive masked values
On 23/07/2020 12:25, Boris Ulasevich wrote:
> Since the JDK-8248414 patch has been committed, I believe we can revive
> this review. I think it is still better to move my rule to the ubfiz
> command group,
> which is in the auto-generated area.
>
> http://cr.openjdk.java.net/~bulasevich/8248870/webrev.02
OK, thanks.
--
Andrew Haley (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the aarch64-port-dev
mailing list