Skip to content

[InstSimplify] Missed optimization: X != Y implies X | Y != 0 #117436

@dtcxzyw

Description

@dtcxzyw

Proof: https://alive2.llvm.org/ce/z/cJ75Ya

define i1 @src(i8 %x, i8 %y) {
entry:
  %cond = icmp ne i8 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  %or = or i8 %x, %y
  %cmp = icmp eq i8 %or, 0
  ret i1 %cmp

if.else:
  ret i1 false
}

define i1 @tgt(i8 %x, i8 %y) {
entry:
  %cond = icmp ne i8 %x, %y
  br i1 %cond, label %if.then, label %if.else

if.then:
  ret i1 false

if.else:
  ret i1 false
}

See also dtcxzyw/llvm-tools#32 and https://discourse.llvm.org/t/tuning-up-constraint-elimination/83213/5?u=dtcxzyw.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions