Skip to content

Cranelift: Inconsistent results from scalar_to_vector #10906

@akldc

Description

@akldc

.clif Test Case

test optimize    
    set opt_level=none
    set preserve_frame_pointers=true
    set enable_multi_ret_implicit_sret=true
    target x86_64 
            
function %main() -> i16x8 fast {
    const0 = 0x560af419d25ee4ab70b6b8ba64146998

block0:
    v3 = iconst.i8 66
    v4 = iconst.i16 0x6342
    v9 = f64const 0x1.3ebf9685e6a16p-2
    v10 = vconst.i8x16 const0
    v11 = vconst.i16x8 const0
    v12 = vconst.i32x4 const0
    v13 = vconst.f32x4 const0
    v14 = vconst.i64x2 const0
    v15 = vconst.f64x2 const0
    jump block2

block2:
    v23 = scalar_to_vector.i16x8 v4
    return v23
}

; print: %main()

Steps to Reproduce

clif-util run -v ./test1.clif

Results

%main() -> 0x00000000000000000000000000006342

Then add a return value v9.

test optimize    
    set opt_level=none
    set preserve_frame_pointers=true
    set enable_multi_ret_implicit_sret=true
    target x86_64 
            
function %main() -> f64, i16x8 fast {
    const0 = 0x560af419d25ee4ab70b6b8ba64146998

block0:
    v3 = iconst.i8 66
    v4 = iconst.i16 0x6342
    v9 = f64const 0x1.3ebf9685e6a16p-2
    v10 = vconst.i8x16 const0
    v11 = vconst.i16x8 const0
    v12 = vconst.i32x4 const0
    v13 = vconst.f32x4 const0
    v14 = vconst.i64x2 const0
    v15 = vconst.f64x2 const0
    jump block2

block2:
    v23 = scalar_to_vector.i16x8 v4
    return v9, v23
}

; print: %main()

Sometimes the result is [0x1.3ebf9685e6a16p-2, 0x00000000000000000000000000006342],
and other times it’s [0x1.3ebf9685e6a16p-2, 0x000000000000000100000000ffff6342].
Why does this inconsistency happen?

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