[llvm-bugs] [Bug 51667] New: Incorrect use information after instcombine impacts inline cost estimate

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 30 02:00:25 PDT 2021


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

            Bug ID: 51667
           Summary: Incorrect use information after instcombine impacts
                    inline cost estimate
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: tomasz.miasko at gmail.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

In LLVM IR below, the h function calls functions f and g with internal linkage.
Neither f or g have any other uses, so both callsites should receive a bonus
for inlining internal function with a single use. The call to f does receive
the bonus, while g does not receive it:

$ opt a.ll -S -instcombine -inline -pass-remarks=inline
remark: <unknown>:0:0: 'f' inlined into 'h' with (cost=-15035, threshold=337)
remark: <unknown>:0:0: 'g' inlined into 'h' with (cost=-35, threshold=337)

Everything works as expected when instcombine and inline passes are run
separately: 

$ opt a.ll -S -instcombine > b.ll
$ opt b.ll -S -inline -pass-remarks=inline 
remark: <unknown>:0:0: 'f' inlined into 'h' with (cost=-15035, threshold=337)
remark: <unknown>:0:0: 'g' inlined into 'h' with (cost=-15035, threshold=337)

LLVM IR:

; ModuleID = 'a.ll'
source_filename = "a.a146b597-cgu.0"
target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%0 = type { i64, i64, i64 }
%1 = type { i64, i64, i64 }

define internal void @f(%0* align 8 %a) unnamed_addr {
start:
  ret void
}

define internal void @g(%0* align 8 %a) unnamed_addr {
start:
  ret void
}

define void @h(%0* align 8 %a, %1* align 8 %b) unnamed_addr {
start:
  call void @f(%0* align 8 %a)
  call void bitcast (void (%0*)* @g to void (%1*)*)(%1* align 8 %b)
  ret void
}

-- 
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/20210830/40c0d99c/attachment.html>


More information about the llvm-bugs mailing list