Skip to content

Fold extend followed by operations that do not care about the extended bits #5005

@kripken

Description

@kripken

E.g.

(i64.eqz
 (i64.extend_i32_u
  (i64.eqz
   (local.get $0)
  )
 )
)
 =->
(i64.ne
 (local.get $0)
 (i64.const 0)
)

Comparing to zero is the same with or without extending: if was zero, it'll remain so, and if it wasn't zero, it still won't be zero.

Found by the superoptimizer #4994 (for comparison to other findings: rule #1, benefit 140074).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions