Skip to content

Cranelift: Misoptimization with select + icmp #12503

@bjorn3

Description

@bjorn3

.clif Test Case

test compile
set opt_level=speed_and_size
set enable_verifier=1
target aarch64

function u0:1360(i8) -> i8 system_v {
block0(v0: i8):
    v1 = iconst.i64 0
    v2 = iconst.i64 1
    v3 = select v0, v1, v2
    v4 = icmp_imm eq v3, 1
    return v4
}

Expected Results

Compiles

Actual Results

function u0:1360(i8) -> i8 system_v {
block0(v0: i8):
    v1 = iconst.i64 0
    v6 = icmp eq v0, v1  ; v1 = 0
;   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; error: inst6 (v6 = icmp.i8 eq v0, v1  ; v1 = 0): arg 1 (v1) has type i64, expected i8

    return v6
}

; 1 verifier error detected (see above). Compilation aborted.

Versions and Environment

Cranelift version or commit: 0.128 and up

Operating system: Any

Architecture: Likely any. Seen on arm64 and x86_64.

Extra Info

This breaks cg_clif when updating to 0.128.2.

Likely a regression from #12135, cc @jameshu15869

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