[clang] [llvm] [Inliner] Propagate inlined.from metadata through intermediate calls (PR #248805)
Jaeyong Lee via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 4 00:00:34 PST 2026
npmania wrote:
For Misc/perlin, the IR after early inlining looks like:
```llvm
loop:
%iv = phi i32 [ 0, %entry ], [ %iv.next, %latch ]
%acc = phi double [ 0.0, %entry ], [ %r, %latch ]
%s0 = select i1 %c0, double %u0, double %nu0
%g0 = fadd double %s0, %v0
br i1 %cond, label %arm, label %latch
arm:
%m = and i32 %h, 13
%eq = icmp eq i32 %m, 12
%v.arm = select i1 %eq, double %x, double %z
br label %latch
latch:
%v1 = phi double [ %y, %loop ], [ %v.arm, %arm ]
%s1 = select i1 %c1, double %u1, double %nu1
%g1 = fadd double %s1, %v1
%diff = fsub double %g1, %g0
%r = fadd double %acc, %diff
%iv.next = add i32 %iv, 1
%done = icmp eq i32 %iv.next, %n
br i1 %done, label %exit, label %loop
```
On default x86_64, SimplifyCFG doesn't flatten %arm, so %s0/%g0 and %s1/%g1 stay in different blocks. Without early inlining, InstCombine sinks %s0/%g0 into the ret block:
https://github.com/llvm/llvm-project/blob/01173c053c39cee2bca7fb78ee1e596ba6f3c014/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp#L5882-L5889
With early inlining, that block becomes the loop latch so it doesn't sink anymore.
Where would be the right place to handle this?
https://github.com/llvm/llvm-project/pull/248805
More information about the cfe-commits
mailing list