diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-20 13:59:24 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-21 16:31:07 +0200 |
commit | 37d3030711cc30564fb142154e4e8cabdc91724e (patch) | |
tree | 4903ba1af3e6cec185cdc7796596749dd1867e01 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 5342dd6bf44455401789c6076bc6c166e914cdf1 (diff) | |
download | llvm-37d3030711cc30564fb142154e4e8cabdc91724e.zip llvm-37d3030711cc30564fb142154e4e8cabdc91724e.tar.gz llvm-37d3030711cc30564fb142154e4e8cabdc91724e.tar.bz2 |
[ValueTracking, BasicAA] Don't simplify instructions
GetUnderlyingObject() (and by required symmetry
DecomposeGEPExpression()) will call SimplifyInstruction() on the
passed value if other checks fail. This simplification is very
expensive, but has little effect in practice. This patch removes
the SimplifyInstruction call(), and replaces it with a check for
single-argument phis (which can occur in canonical IR in LCSSA
form), which is the only useful simplification case I was able to
identify.
At O3 the geomean CTMark improvement is -1.7%. The largest
improvement is SPASS with ThinLTO at -6%.
In test-suite, I see only two tests with a hash difference and
no code size difference (PAQ8p, Ptrdist), which indicates that
the simplification only ends up being useful very rarely. (I would
have liked to figure out which simplification is responsible here,
but wasn't able to spot it looking at transformation logs.)
The AMDGPU test case that is update was using two selects with
undef condition, in which case GetUnderlyingObject will return
the first select operand as the underlying object. This will of
course not happen with non-undef conditions, so this was not
testing anything realistic. Additionally this illustrates potential
unsoundness: While GetUnderlyingObject will pick the first operand,
the select might be later replaced by the second operand, resulting
in inconsistent assumptions about the undef value.
Differential Revision: https://reviews.llvm.org/D82261
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index d01889e..927add4 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4151,11 +4151,14 @@ Value *llvm::GetUnderlyingObject(Value *V, const DataLayout &DL, if (GA->isInterposable()) return V; V = GA->getAliasee(); - } else if (isa<AllocaInst>(V)) { - // An alloca can't be further simplified. - return V; } else { - if (auto *Call = dyn_cast<CallBase>(V)) { + if (auto *PHI = dyn_cast<PHINode>(V)) { + // Look through single-arg phi nodes created by LCSSA. + if (PHI->getNumIncomingValues() == 1) { + V = PHI->getIncomingValue(0); + continue; + } + } else if (auto *Call = dyn_cast<CallBase>(V)) { // CaptureTracking can know about special capturing properties of some // intrinsics like launder.invariant.group, that can't be expressed with // the attributes, but have properties like returning aliasing pointer. @@ -4171,14 +4174,6 @@ Value *llvm::GetUnderlyingObject(Value *V, const DataLayout &DL, } } - // See if InstructionSimplify knows any relevant tricks. - if (Instruction *I = dyn_cast<Instruction>(V)) - // TODO: Acquire a DominatorTree and AssumptionCache and use them. - if (Value *Simplified = SimplifyInstruction(I, {DL, I})) { - V = Simplified; - continue; - } - return V; } assert(V->getType()->isPointerTy() && "Unexpected operand type!"); |