[llvm] r370355 - Allow replaceAndRecursivelySimplify to list unsimplified visitees.
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 02:05:29 PDT 2019
Merged to release_90 in r370447.
On Thu, Aug 29, 2019 at 3:21 PM Joerg Sonnenberger via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: joerg
> Date: Thu Aug 29 06:22:30 2019
> New Revision: 370355
>
> URL: http://llvm.org/viewvc/llvm-project?rev=370355&view=rev
> Log:
> Allow replaceAndRecursivelySimplify to list unsimplified visitees.
>
> This is part of D65280 and split it to avoid ABI changes on the 9.0
> release branch.
>
> Modified:
> llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
> llvm/trunk/lib/Analysis/InstructionSimplify.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/InstructionSimplify.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/InstructionSimplify.h?rev=370355&r1=370354&r2=370355&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Analysis/InstructionSimplify.h (original)
> +++ llvm/trunk/include/llvm/Analysis/InstructionSimplify.h Thu Aug 29 06:22:30 2019
> @@ -31,6 +31,7 @@
> #ifndef LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
> #define LLVM_ANALYSIS_INSTRUCTIONSIMPLIFY_H
>
> +#include "llvm/ADT/SetVector.h"
> #include "llvm/IR/Instruction.h"
> #include "llvm/IR/Operator.h"
> #include "llvm/IR/User.h"
> @@ -261,12 +262,14 @@ Value *SimplifyInstruction(Instruction *
> /// This first performs a normal RAUW of I with SimpleV. It then recursively
> /// attempts to simplify those users updated by the operation. The 'I'
> /// instruction must not be equal to the simplified value 'SimpleV'.
> +/// If UnsimplifiedUsers is provided, instructions that could not be simplified
> +/// are added to it.
> ///
> /// The function returns true if any simplifications were performed.
> -bool replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV,
> - const TargetLibraryInfo *TLI = nullptr,
> - const DominatorTree *DT = nullptr,
> - AssumptionCache *AC = nullptr);
> +bool replaceAndRecursivelySimplify(
> + Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI = nullptr,
> + const DominatorTree *DT = nullptr, AssumptionCache *AC = nullptr,
> + SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr);
>
> /// Recursively attempt to simplify an instruction.
> ///
>
> Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=370355&r1=370354&r2=370355&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
> +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Aug 29 06:22:30 2019
> @@ -5309,14 +5309,16 @@ Value *llvm::SimplifyInstruction(Instruc
> /// If we have a pre-simplified value in 'SimpleV', that is forcibly used to
> /// replace the instruction 'I'. Otherwise, we simply add 'I' to the list of
> /// instructions to process and attempt to simplify it using
> -/// InstructionSimplify.
> +/// InstructionSimplify. Recursively visited users which could not be
> +/// simplified themselves are to the optional UnsimplifiedUsers set for
> +/// further processing by the caller.
> ///
> /// This routine returns 'true' only when *it* simplifies something. The passed
> /// in simplified value does not count toward this.
> -static bool replaceAndRecursivelySimplifyImpl(Instruction *I, Value *SimpleV,
> - const TargetLibraryInfo *TLI,
> - const DominatorTree *DT,
> - AssumptionCache *AC) {
> +static bool replaceAndRecursivelySimplifyImpl(
> + Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI,
> + const DominatorTree *DT, AssumptionCache *AC,
> + SmallSetVector<Instruction *, 8> *UnsimplifiedUsers = nullptr) {
> bool Simplified = false;
> SmallSetVector<Instruction *, 8> Worklist;
> const DataLayout &DL = I->getModule()->getDataLayout();
> @@ -5346,8 +5348,11 @@ static bool replaceAndRecursivelySimplif
>
> // See if this instruction simplifies.
> SimpleV = SimplifyInstruction(I, {DL, TLI, DT, AC});
> - if (!SimpleV)
> + if (!SimpleV) {
> + if (UnsimplifiedUsers)
> + UnsimplifiedUsers->insert(I);
> continue;
> + }
>
> Simplified = true;
>
> @@ -5373,16 +5378,17 @@ bool llvm::recursivelySimplifyInstructio
> const TargetLibraryInfo *TLI,
> const DominatorTree *DT,
> AssumptionCache *AC) {
> - return replaceAndRecursivelySimplifyImpl(I, nullptr, TLI, DT, AC);
> + return replaceAndRecursivelySimplifyImpl(I, nullptr, TLI, DT, AC, nullptr);
> }
>
> -bool llvm::replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV,
> - const TargetLibraryInfo *TLI,
> - const DominatorTree *DT,
> - AssumptionCache *AC) {
> +bool llvm::replaceAndRecursivelySimplify(
> + Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI,
> + const DominatorTree *DT, AssumptionCache *AC,
> + SmallSetVector<Instruction *, 8> *UnsimplifiedUsers) {
> assert(I != SimpleV && "replaceAndRecursivelySimplify(X,X) is not valid!");
> assert(SimpleV && "Must provide a simplified value.");
> - return replaceAndRecursivelySimplifyImpl(I, SimpleV, TLI, DT, AC);
> + return replaceAndRecursivelySimplifyImpl(I, SimpleV, TLI, DT, AC,
> + UnsimplifiedUsers);
> }
>
> namespace llvm {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list