Skip to content

riscv64 infinite recursing during multiplication __muldi3 #459

@johannst

Description

@johannst

When I compile a multiplication on rv64 without the m extension I'll end up in an infinite recursion as:

#2  0x0000000000021318 in core::num::{impl#8}::wrapping_mul (self=0, rhs=257)
    at /home/johannst/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:1249
#3  compiler_builtins::int::{impl#21}::zero_widen_mul (self=0, rhs=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mod.rs:337
#4  0x00000000000218d8 in compiler_builtins::int::mul::Mul::mul<u64> (self=0, rhs=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mul.rs:16
#5  0x0000000000021ea0 in compiler_builtins::int::mul::__muldi3 (a=0, b=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mul.rs:104
#6  0x000000000002177c in compiler_builtins::int::mul::__muldi3::__muldi3 (a=0, b=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/macros.rs:336

#7  0x0000000000021318 in core::num::{impl#8}::wrapping_mul (self=0, rhs=257)
    at /home/johannst/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/num/uint_macros.rs:1249
#8  compiler_builtins::int::{impl#21}::zero_widen_mul (self=0, rhs=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mod.rs:337
#9  0x00000000000218d8 in compiler_builtins::int::mul::Mul::mul<u64> (self=0, rhs=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mul.rs:16
#10 0x0000000000021ea0 in compiler_builtins::int::mul::__muldi3 (a=0, b=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/int/mul.rs:104
#11 0x000000000002177c in compiler_builtins::int::mul::__muldi3::__muldi3 (a=0, b=257)
    at /home/johannst/.cargo/registry/src/git.colasdn.top-1ecc6299db9ec823/compiler_builtins-0.1.71/src/macros.rs:336
...

A potential solution would be to implement the __muldi3 intrinsic for rv64 similar to __mulsi3 for rv32.

To unblock myself I created following patch rv64-muldi3 - b945767, if that would be an acceptable starting point I am happy to create a PR :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions