[PATCH] D20173: [InstCombine] Avoid combining the bitcast of a var that is used as both address and result of the same load instruction

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 09:31:28 PDT 2016


Please add a testcase.

On Wednesday, May 11, 2016, Guozhi Wei <carrot at google.com> wrote:

> Carrot created this revision.
> Carrot added a reviewer: majnemer.
> Carrot added a subscriber: llvm-commits.
>
> This patch fixes https://llvm.org/bugs/show_bug.cgi?id=27703.
>
> In the testcase, the result of a load instruction is used as the address
> of the same instruction, so a bitcast is necessary to change the value type
> to address type, we should avoid to optimize out the bitcast.
>
> http://reviews.llvm.org/D20173
>
> Files:
>   lib/Transforms/InstCombine/InstCombineCasts.cpp
>
> Index: lib/Transforms/InstCombine/InstCombineCasts.cpp
> ===================================================================
> --- lib/Transforms/InstCombine/InstCombineCasts.cpp
> +++ lib/Transforms/InstCombine/InstCombineCasts.cpp
> @@ -1820,6 +1820,10 @@
>
>        auto *LI = dyn_cast<LoadInst>(IncValue);
>        if (LI) {
> +        // If the loaded value is used as the load address in the same
> +        // instruction, bitcast is necessary to change the value type.
> +        if (LI->getOperand(0) == &CI)
> +          return nullptr;
>          if (LI->hasOneUse() && LI->isSimple())
>            continue;
>          // If a LoadInst has more than one use, changing the type of
> loaded
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160511/457f2462/attachment.html>


More information about the llvm-commits mailing list