Skip to content

Cranelift: scoped elaboration duplicates pure operations even when there is no partial redundancy to avoid #8959

Open
@meithecatte

Description

@meithecatte

.clif Test Case

test optimize
set opt_level=speed
target x86_64

function %f(i32, i32, i32) -> i32 {
block0(v0: i32, v1: i32, v2: i32):
    v3 = imul.i32 v0, v1
    brif v2, block1, block2
block1:
    return v3
block2:
    v4 = iconst.i32 1
    v5 = iadd.i32 v3, v4
    return v5

}

;; check that the two occurrences of v3 are still the same value after optimization
; check: return v3
; check: iadd.i32 v3, v4

Steps to Reproduce

  • clif-util test meow.clif

Expected Results

The imul stays in block0.

Actual Results

The imul is needlessly duplicated between block1 and block2.

Versions and Environment

Cranelift version or commit: de29ce3 (main at the time of writing)

Operating system: Linux

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