[aarch64] assert(is_power_of_2(x)) failed: x must be a power of 2: 0xffffffff80000000
Schmidt, Lutz
lutz.schmidt at sap.com
Mon Feb 24 15:51:47 UTC 2020
Hi,
I would locate the real bug in is_power_of_2(jint). Why?
The function is passed in a jint (= signed int) of value 0x8000_0000. This clearly is a negative number. There does not exist a negative number which is a power of 2.
Separate from that, exact_log2(jint) sign-extends the passed-in value to long, creating a bit pattern which obviously is not a power of two.
A possible fix would include:
- make is_power_of_2() and exact_log_2() sign-aware.
- call is_power_of_2() and exact_log_2() with arguments of proper type (juint in this case).
Regards,
Lutz
On 24.02.20, 15:18, "hotspot-compiler-dev on behalf of Andrew Haley" <hotspot-compiler-dev-bounces at openjdk.java.net on behalf of aph at redhat.com> wrote:
On 2/24/20 1:47 PM, Doerr, Martin wrote:
> I've created an issue:
> https://bugs.openjdk.java.net/browse/JDK-8239861
>
> Failues were observed in e.g. jck tests api/java_awt/Font/LineBreakMeasurer.
This is caused by "8183574: Unify the is_power_of_2 functions".
I think there's a real bug in the new exact_log2().
is_power_of_2((jint)0x8000_0000) returns true but
exact_log2((jint)0x8000_0000) throws an exception. This sounds wrong
to me. We should work around it in the AArch64 back end by converting
the operand to an unsigned type, but I wonder what else broke.
Here:
instruct far_cmpI_branch_bit(cmpOpEqNe cmp, iRegIorL2I op1, immI op2, immI0 op3, label labl) %{
match(If cmp (CmpI (AndI op1 op2) op3));
predicate(is_power_of_2(n->in(2)->in(1)->in(2)->get_int()));
effect(USE labl);
ins_cost(BRANCH_COST);
format %{ "tb$cmp $op1, $op2, $labl" %}
ins_encode %{
Label* L = $labl$$label;
Assembler::Condition cond = (Assembler::Condition)$cmp$$cmpcode;
int bit = exact_log2($op2$$constant);
Note that we check that $op2 is a power of two before we call
exact_log2().
--
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
More information about the hotspot-compiler-dev
mailing list