Skip to content

Missed optimization: failure to remove dead edge #165179

@kevina

Description

@kevina

From discourse discussion: https://discourse.llvm.org/t/missed-optimization-due-to-overflow-check/88700

Godbolt link: https://godbolt.org/z/xqW3rcnKd.

Relevant IR code.

_ZN4FracC2Eii.exit.i:
  %0 = phi i32 [ 1, %if.else.i.i ], [ -1, %if.end10.i.i ]
  ...

lor.lhs.false.i:
  switch i32 %0, label %if.end.i [
    i32 1, label %_ZN7ReducedC2Eii.exit
    i32 -1, label %_ZN7ReducedC2Eii.exit
  ]

if.end.i:
  call void @Reduced::reduce_in_place()(ptr noundef nonnull align 4 dereferenceable(8) %retval)
  br label %_ZN7ReducedC2Eii.exit

_ZN7ReducedC2Eii.exit:
  %1 = load i64, ptr %retval, align 8
  ret i64 %1
}

From %0 = phi i32 [ 1, %if.else.i.i ], [ -1, %if.end10.i.i ] it should be obvious that %0 can only be 1 or -1 yet LLVM doesn't see it and fails to remove the dead edge.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions