[PATCH] GVN: If a branch has two identical successors, we cannot declare either dead.

Daniel Berlin dberlin at dberlin.org
Thu Jun 25 12:55:37 PDT 2015


On Thu, Jun 25, 2015 at 12:52 AM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> Hi spatel,
>
> This previously caused miscompilations as a result of phi nodes receiving
> undef incoming values from blocks dominated by such successors.
>
> http://reviews.llvm.org/D10726
>
> Files:
>   lib/Transforms/Scalar/GVN.cpp
>   test/Transforms/GVN/br-identical.ll
>
> Index: lib/Transforms/Scalar/GVN.cpp
> ===================================================================
> --- lib/Transforms/Scalar/GVN.cpp
> +++ lib/Transforms/Scalar/GVN.cpp
> @@ -2808,6 +2808,10 @@
>    if (!BI || BI->isUnconditional())
>      return false;
>
> +  // If a branch has two identical successors, we cannot declare either dead.
> +  if (BI->getSuccessor(0) == BI->getSuccessor(1))
> +    return false;
> +

This is trivially correct.
Please commit.

It doesn't look like we try to mark anything else as dead (IE switch
locations), so i don't think any further fixes are necessary on that
front.



More information about the llvm-commits mailing list