1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/lib/Analysis
Florian Hahn aba875a2e8 [ValueLattice] Distinguish between constant ranges with/without undef.
This patch updates ValueLattice to distinguish between ranges that are
guaranteed to not include undef and ranges that may include undef.

A constant range guaranteed to not contain undef can be used to simplify
instructions to arbitrary values. A constant range that may contain
undef can only be used to simplify to a constant. If the value can be
undef, it might take a value outside the range. For example, consider
the snipped below

define i32 @f(i32 %a, i1 %c) {
  br i1 %c, label %true, label %false
true:
  %a.255 = and i32 %a, 255
  br label %exit
false:
  br label %exit
exit:
  %p = phi i32 [ %a.255, %true ], [ undef, %false ]
  %f.1 = icmp eq i32 %p, 300
  call void @use(i1 %f.1)
  %res = and i32 %p, 255
  ret i32 %res
}

In the exit block, %p would be a constant range [0, 256) including undef as
%p could be undef. We can use the range information to replace %f.1 with
false because we remove the compare, effectively forcing the use of the
constant to be != 300. We cannot replace %res with %p however, because
if %a would be undef %cond may be true but the  second use might not be
< 256.

Currently LazyValueInfo uses the new behavior just when simplifying AND
instructions and does not distinguish between constant ranges with and
without undef otherwise. I think we should address the remaining issues
in LVI incrementally.

Reviewers: efriedma, reames, aqjune, jdoerfert, sstefan1

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D76931
2020-03-31 12:50:20 +01:00
..
AliasAnalysis.cpp [IR] Lazily number instructions for local dominance queries 2020-02-18 14:44:24 -08:00
AliasAnalysisEvaluator.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
AliasAnalysisSummary.cpp Move CFLGraph and the AA summary code over to the new CallBase 2019-02-11 09:25:41 +00:00
AliasAnalysisSummary.h Move CFLGraph and the AA summary code over to the new CallBase 2019-02-11 09:25:41 +00:00
AliasSetTracker.cpp [NFC] Remove trailing space 2020-02-18 10:49:13 +08:00
Analysis.cpp [MustExec] Add a generic "must-be-executed-context" explorer 2019-08-23 15:17:27 +00:00
AssumptionCache.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
BasicAliasAnalysis.cpp Introduce support for lib function aligned_alloc in TLI / memory builtins 2020-03-29 23:36:24 +05:30
BlockFrequencyInfo.cpp [CFG/BasicBlock] Rename succ_const to const_succ. [NFC] 2020-03-25 12:40:55 -07:00
BlockFrequencyInfoImpl.cpp [BFI] Add a debug check for unknown block queries. 2020-02-04 10:05:28 -08:00
BranchProbabilityInfo.cpp [CFG/BasicBlock] Rename succ_const to const_succ. [NFC] 2020-03-25 12:40:55 -07:00
CallGraph.cpp Introduce a CallGraph updater helper class 2020-02-08 14:16:48 -06:00
CallGraphSCCPass.cpp Introduce a CallGraph updater helper class 2020-02-08 14:16:48 -06:00
CallPrinter.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
CaptureTracking.cpp [IR] Lazily number instructions for local dominance queries 2020-02-18 14:44:24 -08:00
CFG.cpp [CFG/BasicBlock] Rename succ_const to const_succ. [NFC] 2020-03-25 12:40:55 -07:00
CFGPrinter.cpp Flags for displaying only hot nodes in CFGPrinter graph 2020-02-21 17:20:00 -08:00
CFLAndersAliasAnalysis.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
CFLGraph.h [CFLGraph] Add support for unary fneg instruction. 2019-06-06 19:21:23 +00:00
CFLSteensAliasAnalysis.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
CGSCCPassManager.cpp Extend TimeTrace to LLVM's new pass manager 2020-03-06 14:45:19 -08:00
CMakeLists.txt [LoopNest]: Analysis to discover properties of a loop nest. 2020-03-03 18:25:19 +00:00
CmpInstAnalysis.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CodeMetrics.cpp Remove CallSite from the CodeMetrics analysis, moving it to the new 2019-02-11 09:03:32 +00:00
ConstantFolding.cpp [FEnv] Constfold some unary constrained operations 2020-03-28 12:28:33 +07:00
CostModel.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
DDG.cpp [DDG] Data Dependence Graph - Graph Simplification 2020-02-19 13:41:51 -05:00
Delinearization.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
DemandedBits.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
DependenceAnalysis.cpp [DA] Delinearization of fixed-size multi-dimensional arrays 2020-02-27 10:29:01 -05:00
DependenceGraphBuilder.cpp [DDG] Data Dependence Graph - Graph Simplification 2020-02-19 13:41:51 -05:00
DivergenceAnalysis.cpp [DA] Don't propagate from unreachable blocks 2020-01-24 10:28:11 -08:00
DominanceFrontier.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
DomPrinter.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
DomTreeUpdater.cpp [NFC] Fixes -Wrange-loop-analysis warnings 2020-01-01 20:01:37 +01:00
EHPersonalities.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
GlobalsModRef.cpp [GlobalsModRef] Add invalidate method 2020-01-17 10:33:54 -08:00
GuardUtils.cpp [NFC] Remove trailing space 2020-02-18 10:49:13 +08:00
IndirectCallPromotionAnalysis.cpp Add missing includes needed to prune LLVMContext.h include, NFC 2019-11-14 15:23:15 -08:00
InlineCost.cpp [Inliner] Inlining should honor nobuiltin attributes 2020-02-28 07:34:14 -08:00
InstCount.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
InstructionPrecedenceTracking.cpp [NFC] Remove obsolete checks followed by fix of isGuaranteedToTransferExecutionToSuccessor 2020-03-30 12:24:41 +07:00
InstructionSimplify.cpp [FEnv] Constfold some unary constrained operations 2020-03-28 12:28:33 +07:00
Interval.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IntervalPartition.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
IVDescriptors.cpp [SCEV] Remove unused ScalarEvolutionExpander.h includes (NFC). 2020-01-04 18:29:35 +00:00
IVUsers.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
LazyBlockFrequencyInfo.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
LazyBranchProbabilityInfo.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
LazyCallGraph.cpp [LazyCallGraph] Fix ambiguous index value 2020-02-18 23:32:55 -05:00
LazyValueInfo.cpp [ValueLattice] Distinguish between constant ranges with/without undef. 2020-03-31 12:50:20 +01:00
LegacyDivergenceAnalysis.cpp Resubmit: [DA][TTI][AMDGPU] Add option to select GPUDA with TTI 2020-01-24 10:39:40 -08:00
Lint.cpp [ConstantFolding] Always return something from ConstantFoldConstant 2020-03-04 18:24:47 +01:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Loads.cpp [NFC] Remove trailing space 2020-02-18 10:49:13 +08:00
LoopAccessAnalysis.cpp [VectorUtils] Rework the Vector Function Database (VFDatabase). 2020-01-16 15:08:26 +00:00
LoopAnalysisManager.cpp Add PassManagerImpl.h to hide implementation details 2020-02-03 11:15:55 -08:00
LoopCacheAnalysis.cpp [LoopCacheAnalysis]: Add support for negative stride 2020-02-10 13:22:35 -05:00
LoopInfo.cpp Rename LoopInfo::isRotated() to LoopInfo::isRotatedForm(). 2019-12-12 14:22:36 -05:00
LoopNestAnalysis.cpp [LoopNest]: Analysis to discover properties of a loop nest. 2020-03-03 18:25:19 +00:00
LoopPass.cpp NFC. Remove obsolete SimpleAnalysis infrastructure 2020-01-23 13:58:30 +07:00
LoopUnrollAnalyzer.cpp [InstSimplify] Rename SimplifyFPUnOp and SimplifyFPBinOp 2019-07-24 12:50:10 +00:00
MemDepPrinter.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
MemDerefPrinter.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
MemoryBuiltins.cpp Introduce support for lib function aligned_alloc in TLI / memory builtins 2020-03-29 23:36:24 +05:30
MemoryDependenceAnalysis.cpp [DependenceAnalysis] Dependecies for loads marked with "ivnariant.load" should not be shared with general accesses(PR42151). 2020-03-04 18:40:02 +07:00
MemoryLocation.cpp [IR] Split out target specific intrinsic enums into separate headers 2019-12-11 18:02:14 -08:00
MemorySSA.cpp [MemorySSA] Don't verify MemorySSA unless VerifyMemorySSA enabled 2020-02-13 18:46:58 +01:00
MemorySSAUpdater.cpp [MemorySSA] Moving at the end often means before terminator. 2019-11-20 17:11:00 -08:00
ModuleDebugInfoPrinter.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
ModuleSummaryAnalysis.cpp [NFC] Remove trailing space 2020-02-18 10:49:13 +08:00
MustExecute.cpp [Attributor] Detect possibly unbounded cycles in functions 2020-03-13 11:17:33 -05:00
ObjCARCAliasAnalysis.cpp [AliasAnalysis] Second prototype to cache BasicAA / anyAA state. 2019-03-22 17:22:19 +00:00
ObjCARCAnalysisUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ObjCARCInstKind.cpp [ObjC][ARC] Delete ObjC runtime calls on global variables annotated 2019-06-14 22:06:32 +00:00
OptimizationRemarkEmitter.cpp Compute ORE, BPI, BFI in Loop passes. 2020-02-12 09:15:18 -08:00
OrderedInstructions.cpp [IR] Lazily number instructions for local dominance queries 2020-02-18 14:44:24 -08:00
PHITransAddr.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PhiValues.cpp [PhiValues] Remove redundant map searches 2019-11-23 10:32:56 +02:00
PostDominators.cpp [CodeMoverUtils] Added an API to check if an instruction can be safely 2019-11-22 21:29:08 +00:00
ProfileSummaryInfo.cpp [PSI] Add the isCold query support with a given percentile value. 2020-03-02 12:50:15 -08:00
PtrUseVisitor.cpp SROA: Allow eliminating addrspacecasted allocas 2019-06-14 21:38:31 +00:00
README.txt
RegionInfo.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
RegionPass.cpp [IR] Refactor attribute methods in Function class (NFC) 2019-04-04 22:40:06 +00:00
RegionPrinter.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
ScalarEvolution.cpp [SCEV] Use backedge SCEV of PHI only if its input is loop invariant 2020-03-31 18:39:24 +07:00
ScalarEvolutionAliasAnalysis.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
ScalarEvolutionExpander.cpp [NFCI][SCEV] Avoid recursion in SCEVExpander::isHighCostExpansion*() 2020-03-18 17:10:54 +03:00
ScalarEvolutionNormalization.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScopedNoAliasAA.cpp Sink all InitializePasses.h includes 2019-11-13 16:34:37 -08:00
StackSafetyAnalysis.cpp [memtag] Plug in stack safety analysis. 2020-03-16 16:35:25 -07:00
StratifiedSets.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SyncDependenceAnalysis.cpp [CFG/BasicBlock] Rename succ_const to const_succ. [NFC] 2020-03-25 12:40:55 -07:00
SyntheticCountsUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TargetLibraryInfo.cpp Introduce support for lib function aligned_alloc in TLI / memory builtins 2020-03-29 23:36:24 +05:30
TargetTransformInfo.cpp TTI: Add addrspace parameters to memcpy lowering functions 2020-03-16 14:34:29 -04:00
Trace.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TypeBasedAliasAnalysis.cpp [Metadata] Add TBAA struct metadata to AAMDNode 2020-01-06 11:05:15 +03:00
TypeMetadataUtils.cpp Reland: Dead Virtual Function Elimination 2019-10-17 09:58:57 +00:00
ValueLattice.cpp [ValueLattice] Distinguish between constant ranges with/without undef. 2020-03-31 12:50:20 +01:00
ValueLatticeUtils.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ValueTracking.cpp [ConstantFold][NFC] Compile time optimization for large vectors 2020-03-30 11:27:09 -07:00
VectorUtils.cpp [InstSimplify][SVE] Fix SimplifyInsert/ExtractElementInst for scalable vector. 2020-03-11 15:09:56 -07:00
VFABIDemangling.cpp [llvm][VectorUtils] Tweak VFShape for scalable vector functions. 2020-01-30 05:53:56 +00:00

Analysis Opportunities:

//===---------------------------------------------------------------------===//

In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
ScalarEvolution expression for %r is this:

  {1,+,3,+,2}<loop>

Outside the loop, this could be evaluated simply as (%n * %n), however
ScalarEvolution currently evaluates it as

  (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))

In addition to being much more complicated, it involves i65 arithmetic,
which is very inefficient when expanded into code.

//===---------------------------------------------------------------------===//

In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,

ScalarEvolution is forming this expression:

((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))

This could be folded to

(-1 * (trunc i64 undef to i32))

//===---------------------------------------------------------------------===//