Stream: cranelift

Topic: ✔ Arrow statements


view this post on Zulip kmeakin (Mar 17 2023 at 19:54):

What do arrow statements in CLIF mean?
eg

function %mul_minus_one_commuted(i32) -> i32 {
block0(v0: i32):
    v1 = iconst.i32 0xffff_ffff ; -1
    v2 = imul v1, v0
    return v2
    ; check: v3 = ineg v0
    ; check: v5 -> v3
    ; check: v6 -> v3
    ; check: return v3
}

view this post on Zulip Dan Gohman (Mar 17 2023 at 20:03):

Those are value aliases, so v5 is an alias of v3, and so on.

view this post on Zulip kmeakin (Mar 17 2023 at 20:06):

Ok. But why do the aliases exist in the first place?

view this post on Zulip Chris Fallin (Mar 17 2023 at 20:07):

they allow for rewrites without editing all use-sites

view this post on Zulip kmeakin (Mar 17 2023 at 20:09):

I see. So at some point a v5 and v6 were referenced somewhere?

view this post on Zulip fitzgen (he/him) (Mar 17 2023 at 20:15):

presumably in intermediate forms in the e-graph, but which were ultimately not selected during extraction

view this post on Zulip kmeakin (Mar 17 2023 at 20:27):

cool

view this post on Zulip kmeakin (Mar 17 2023 at 20:28):

maybe we could remove dead aliases from IR before its emitted? Would make more concise/readable output

view this post on Zulip bjorn3 (Mar 17 2023 at 20:36):

That would lose information. It is possible to replace an alias with another alias or a regular instruction again.

view this post on Zulip Chris Fallin (Mar 17 2023 at 20:48):

yes, it's useful to have a 1:1 dump of the actual IR data structure; if it becomes an issue for readable dumps at various points I suppose we could have simplification passes (DCE would be another useful one when printing) that can run before debug dumps

view this post on Zulip bjorn3 (Mar 17 2023 at 22:20):

We do have resolve_aliases to replace all alias uses with their definition and we also don't print unused aliases, so just calling resolve_aliases before printing would be enough to remove all aliases from the output.

view this post on Zulip Notification Bot (Mar 21 2023 at 20:45):

kmeakin has marked this topic as resolved.


Last updated: Dec 23 2024 at 13:07 UTC