Skip to content

Loop passes (indvars) do not simplify the CFG before other loop passes run (loop-deletion). #18823

Open
@dotdash

Description

@dotdash
Bugzilla Link 18449
Version unspecified
OS Linux
CC @atrick,@hfinkel

Extended Description

Given this code:

; ModuleID = '<stdin>'

define void @&#8203;test() {
"function top level":
  br label %loop

loop:                                             ; preds = %body, %"function top level"
  %0 = phi i64 [ 0, %"function top level" ], [ %2, %body ]
  %1 = icmp ugt i64 %0, 2
  br i1 %1, label %fail, label %body

fail:                                             ; preds = %loop
  tail call void @&#8203;bounds_fail()
  unreachable

body:                                             ; preds = %loop
  %2 = add i64 %0, 1
  %3 = icmp slt i64 %2, 3
  br i1 %3, label %loop, label %out

out:                                              ; preds = %body
  ret void
}

declare void @&#8203;bounds_fail()

opt from LLVM 3.2 was able to optimize that to:

; ModuleID = '<stdin>'

define void @&#8203;test() {
body.2:
  ret void
}

But opt from LLVM 3.3, 3.4 and 3.5~svn197556-1 (from Debian Sid) fail to do so and leave the code unchanged.

This is from rust issue rust-lang/rust#9024

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions