[llvm-bugs] [Bug 38933] New: [licm] LICM cannot hoist load of global with llvm.invariant.start

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 13 07:34:05 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38933

            Bug ID: 38933
           Summary: [licm] LICM cannot hoist load of global with
                    llvm.invariant.start
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: mpfergu at gmail.com
                CC: llvm-bugs at lists.llvm.org

I have a global variable and have marked it with llvm.invariant.start.
I would expect LICM to hoist the load of the global variable out of a loop
under these conditions, but it does not.

One potential issue is that isLoadInvariantInLoop only handles the case when
the load address refers one or more bitcast instructions, which is not true in
this example.

Try this with opt test.ll -licm -S


@chpl_privateObjects = external dso_local global i8**, align 8

declare void @foo()

declare {}* @llvm.invariant.start.p0i8(i64, i8* nocapture) nounwind readonly
declare void @llvm.invariant.end.p0i8({}*, i64, i8* nocapture) nounwind

define i8 @test_licm_global(i32 %n) {

entry:
  %invst = tail call {}* @llvm.invariant.start.p0i8(i64 8, i8* bitcast (i8***
@chpl_privateObjects to i8*)) #4
  br label %loop

loop:
  %indvar = phi i32 [ %indvar.next, %loop ], [ 0, %entry ]
  %sum = phi i8 [ %sum.next, %loop ], [ 0, %entry ]

  %g = load i8**, i8*** @chpl_privateObjects, align 8
  %p = load i8*, i8** %g, align 8
  %v = load i8, i8* %p, align 8

  call void @foo()

  %sum.next = add i8 %v, %sum
  %indvar.next = add i32 %indvar, 1
  %cond = icmp slt i32 %indvar.next, %n
  br i1 %cond, label %loop, label %loopexit

loopexit:
  ret i8 %sum
}

attributes #4 = { nounwind }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180913/c3832545/attachment.html>


More information about the llvm-bugs mailing list