Skip to content

Turn shl+shr of the same amount into a mask #5012

@kripken

Description

@kripken

E.g.

(i32.shl
 (i32.shr_u
  (local.get $0)
  (i32.const 4)
 )
 (i32.const 4)
)
 =->
(i32.and
 (local.get $0)
 (i32.const -16) ;; 0xfffffff0
)

We optimize the reverse, x << 16 >> 16 becomes a sign-extend, but not this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions