[LLVMdev] Loops Prevent Function Pointer Inlining?
Nicholas White
n.j.white at gmail.com
Wed Sep 24 16:11:38 PDT 2014
I've CC'ed Chad Rosier as I think this behaviour is a side-effect of
his revert of IndVarSimplify.cpp (git
c6b1a7e577a0b9e9cff9f9b7ac35a2cde7c448d8, SVN 217962). The change
basically makes the IndVar pass change:
; <label>:4 ; preds = %6, %0
%i.0 = phi i32 [ 0, %0 ], [ %11, %6 ]
%5 = icmp eq i32 %i.0, 0
br i1 %5, label %6, label %17
To:
; <label>:4 ; preds = %7, %0
%indvars.iv = phi i64 [ %indvars.iv.next, %7 ], [ 0, %0 ]
%5 = trunc i64 %indvars.iv to i32
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %15
Whereas before the patch it would be:
; <label>:4 ; preds = %7, %0
%indvars.iv = phi i64 [ %indvars.iv.next, %7 ], [ 0, %0 ]
%5 = icmp eq i64 %indvars.iv, 0
br i1 %5, label %6, label %15
This has a knock-on effect on the GVN pass; in the basic block that is
the body of the loop it only knows that "trunc i64 %indvars.iv to i32"
is zero, not that "%indvars.iv" is zero, so it can't convert the "add
i64 %indvars.iv, 1" to a constant 1, and so doesn't realise the body
of the loop is only ever executed once.
I'll keep digging...
Thanks,
Nick
More information about the llvm-dev
mailing list