Skip to content

[InstCombine] Simplify range check + mask check #158326

@nikic

Description

@nikic

https://alive2.llvm.org/ce/z/8asCzz

define i1 @src(i8 %a) {
  %cmp1 = icmp ult i8 %a, 5
  %masked = and i8 %a, -2
  %cmp2 = icmp eq i8 %masked, 2
  %and = and i1 %cmp1, %cmp2
  ret i1 %and
}

define i1 @tgt(i8 %a) {
  %masked = and i8 %a, -2
  %cmp2 = icmp eq i8 %masked, 2
  ret i1 %cmp2
}

In this example the mask check only satisfies 2 and 3, both of which are < 5, so the range check is redundant.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions