[llvm-dev] [GVN] same sequence of instructions in if and else branch

Jingyue Wu via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 9 12:02:05 PST 2016


I believe SimplifyCFG instead of GVN does that:
http://llvm.org/docs/doxygen/html/SimplifyCFG_8cpp_source.html#l01080

On Tue, Feb 9, 2016 at 11:30 AM, Taewook Oh via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello,
>
>
> I found that GVN doesn't promote identical sequence of instructions in if
> and else branch to their common predecessors. For example, for the
> following code snippet
>
>
> pred:
>
>>
> br i1 %cmp, label %if, label %else
>
> if:
>
> %incdec.ptr.1 = getelementptr inbounds i8, i8* %ptr, i64 1
>
> %cast1 = ptrtoint i8* %incdec.ptr.1 to i64
>
>>
> else:
>
> %incdec.ptr.2 = getelementptr inbounds i8, i8* %ptr, i64 1
>
> %cast2 = ptrtoint i8* %incdec.ptr.2 to i64
>
>
> GVN doesn't move instructions in 'if' and 'else' blocks to 'pred' block
> even though it knows that incdec.ptr.1/case1 has a same value number with
> incdec.ptr.2/cast2. I see a case where this kind of redundancy confuses
> following optimization passes and ends up generating suboptimal code.
>
>
> From the GVN implementation, it seems that transformation is performed
> only when the "leader" value dominates the other value, so it cannot handle
> a case like the above example. I wonder if this is by design or just a
> missing feature.
>
>
> Thanks,
>
> Taewook
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160209/e08b6ff1/attachment.html>


More information about the llvm-dev mailing list