Skip to content

Cranelift: iconst.i128 stores the wrong value for i128 values #2906

@afonso360

Description

@afonso360

When implmenting i128 support for aarch64 I found that iconst is not correctly storing i128 values on x86_64.

It looks like the issue is that we store constants as u64's in machineinst/lower.rs, which then gets wrongly lowered to i128's.

.clif Test Case

test run
target x86_64

function %i128_const_neg_1() -> i64, i64 {
block0:
    v1 = iconst.i128 -1
    v2, v3 = isplit v1
    return v2, v3
}
; run: %i128_const_neg_1() == [0xffffffff_ffffffff, 0xffffffff_ffffffff]

Steps to Reproduce

clif-util test ./the_above.clif

Expected Results

Returns [-1, -1]

Actual Results

Returns [-1, 0]

Versions and Environment

Cranelift version or commit: e676589 (main as of writing this)

Operating system: Windows 10 19042.928

Architecture: x86_64

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingcraneliftIssues related to the Cranelift code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions