[llvm-commits] Do more conditional propagation in GVN

Peter Cooper peter_cooper at apple.com
Sun Feb 26 12:17:53 PST 2012

Hi Duncan

Sorry, you sent me this quite a while ago and I never got back to you about it. I think it's very worthwhile. I was trying to do something similar in SimplifyCfg but it was getting very messy.


Sent from my iPhone

On Feb 26, 2012, at 10:06 AM, Duncan Sands <baldrick at free.fr> wrote:

> Hi all, suppose we have
>    %cmp = icmp eq i32 %x, %y
>    br i1 %cmp, label %same, label %different
>  same:
>    %cmp2 = icmp eq i32 %x, %y
>    %cmp3 = icmp ne i32 %x, %y
> Right now GVN will replace %cmp2 with "true" because you can only get to
> block "same" if %cmp is true, and %cmp2 is the same as %cmp.  But it
> doesn't replace %cmp3 with false.  The attached patch implements this
> (when the branch condition is any comparison, not just an equality
> comparison).  Currently no pass does this (tested using -std-compile-opts).
> The logic fires here and there.  It zaps two compares and two blocks in bzip2
> because the compares were replaced with constants thanks to this.  In "gcc as
> one big file" it zaps 50 or so comparisons, resulting in some minor knock-on
> simplifications.  On sqlite3, which showed the most compile time slowdown when
> the original logic was implemented, the compile time goes up by 2%, while in
> return it zaps about 40 or so comparisons resulting in some minor knock-on
> simplifications.
> I didn't implement this because I needed it, I implemented it because I
> realized that it could be done quite easily.  But is it worth it?  Any
> opinions?
> Ciao, Duncan.
> <oppprop.diff>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

More information about the llvm-commits mailing list