Recommit "[LICM] Only create load in ph when promoting load or store doesn't exec."
authorFlorian Hahn <flo@fhahn.com>
Sun, 29 May 2022 20:57:14 +0000 (21:57 +0100)
committerFlorian Hahn <flo@fhahn.com>
Sun, 29 May 2022 20:57:14 +0000 (21:57 +0100)
commit0776c48f9b7e69fa447bee57c7c0985caa856be9
tree2abec5438df1aba1464bc30bde758dd641d30d0a
parent9a3144d078389c19b269b8dd94b9f5306754c039
Recommit "[LICM] Only create load in ph when promoting load or store doesn't exec."

This reverts the revert commit ad95255b9215a.

The updated version also creates a load when the store may not execute.
In those cases, we still need to introduce a load in a function where
there may not have been one before, so this doesn't completely resolve
issue #51248.

Original message:

    When only a store is sunk, there is no need to create a load in the
    pre-header, as the result of the load will never get used.

    The dead load can can introduce UB, if the function is marked as
    writeonly.

    Reviewed By: nikic

    Differential Revision: https://reviews.llvm.org/D123473
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/scalar-promote.ll