llvm-project/llvm/lib/Analysis
Roman Lebedev e9289dc25f
[InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform
The transform wasn't checking that the LHS of the comparison
*is* the `X` in question...
This is the miscompile that was holding up D87188.

Thanks to Dave Green for producing an actionable reproducer!
2020-12-18 21:18:13 +03:00
..
models/inliner [MLInliner] Simplify TFUTILS_SUPPORTED_TYPES 2020-08-25 14:19:39 -07:00
AliasAnalysis.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
AliasAnalysisEvaluator.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
AliasAnalysisSummary.cpp AliasAnalysisSummary.h - cleanup includes and forward declarations. NFC. 2020-04-21 11:32:58 +01:00
AliasAnalysisSummary.h AliasAnalysisSummary.h - cleanup includes and forward declarations. NFC. 2020-04-21 11:32:58 +01:00
AliasSetTracker.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
Analysis.cpp [NPM] Port module-debuginfo pass to the new pass manager 2020-10-19 14:31:17 -07:00
AssumeBundleQueries.cpp Reland [AssumeBundles] Use operand bundles to encode alignment assumptions 2020-09-12 15:36:06 +02:00
AssumptionCache.cpp [Analysis] Use llvm::erase_value (NFC) 2020-12-14 22:40:13 -08:00
BasicAliasAnalysis.cpp Revert "[BasicAA] Handle two unknown sizes for GEPs" 2020-12-18 17:59:12 +00:00
BlockFrequencyInfo.cpp [BFI][CGP] Add limited support for detecting missed BFI updates and fix one in CodeGenPrepare. 2020-05-07 11:58:00 -07:00
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp [BPI] Look through bitcasts in calcZeroHeuristic 2020-11-17 09:33:05 -08:00
CFG.cpp [Analysis] Use is_contained (NFC) 2020-12-11 21:19:31 -08:00
CFGPrinter.cpp [DDG] Data Dependence Graph - DOT printer - recommit 2020-12-16 12:37:36 -05:00
CFLAndersAliasAnalysis.cpp [MemLoc] Use hasValue() method (NFC) 2020-11-19 21:53:50 +01:00
CFLGraph.h
CFLSteensAliasAnalysis.cpp
CGSCCPassManager.cpp [NFC] Inline maxDevirtIterationsReached() 2020-12-10 22:12:29 -08:00
CMakeLists.txt [DDG] Data Dependence Graph - DOT printer - recommit 2020-12-16 12:37:36 -05:00
CallGraph.cpp [CallGraph] Preserve call records vector when replacing call edge 2020-07-27 06:02:55 -07:00
CallGraphSCCPass.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
CallPrinter.cpp [DDG] Data Dependence Graph - DOT printer - recommit 2020-12-16 12:37:36 -05:00
CaptureTracking.cpp [CaptureTracking] Add statistics (NFC) 2020-11-07 12:57:00 +01:00
CmpInstAnalysis.cpp
CodeMetrics.cpp CodeMetrics.cpp - remove unused includes. NFC. 2020-05-10 16:59:55 +01:00
ConstantFolding.cpp [llvm][IR] Add dso_local_equivalent Constant 2020-11-19 10:26:17 -08:00
ConstraintSystem.cpp [ConstraintElimination] Bail out if system gets too big. 2020-12-06 20:19:15 +00:00
CostModel.cpp [Support] Introduce a new InstructionCost class 2020-12-11 08:12:54 +00:00
DDG.cpp
DDGPrinter.cpp [DDG] Data Dependence Graph - DOT printer - recommit 2020-12-16 12:37:36 -05:00
Delinearization.cpp [Delinearization][NewPM] Port delinearization to NPM 2020-09-21 17:59:08 -07:00
DemandedBits.cpp [DemandedBits][BDCE] Add support for min/max intrinsics 2020-09-10 22:13:31 +02:00
DependenceAnalysis.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
DependenceGraphBuilder.cpp SmallPtrSet::find -> SmallPtrSet::count 2020-06-07 22:38:08 +02:00
DevelopmentModeInlineAdvisor.cpp [NFC][TFUtils] also include output specs lookup logic in loadOutputSpecs 2020-11-18 21:20:21 -08:00
DivergenceAnalysis.cpp [Analysis] Remove unused system header includes 2020-11-22 10:32:37 +00:00
DomPrinter.cpp
DomTreeUpdater.cpp [Analysis] Use llvm::is_contained (NFC) 2020-11-20 18:08:05 -08:00
DominanceFrontier.cpp
EHPersonalities.cpp [XCOFF][AIX] Generate LSDA data and compact unwind section on AIX 2020-12-02 18:42:44 +00:00
FunctionPropertiesAnalysis.cpp Use llvm::size rather than an empty loop to get the number of top 2020-07-23 14:55:50 -07:00
GlobalsModRef.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
GuardUtils.cpp
HeatUtils.cpp [CallPrinter] Remove static constructor. 2020-06-17 13:02:58 +02:00
IRSimilarityIdentifier.cpp [IRSim] Adding wrapper pass for IRSimilarityIdentfier 2020-09-24 14:59:41 -05:00
IVDescriptors.cpp [IVDescriptors] Remove getConsecutiveDirection (NFC) 2020-12-17 20:19:15 -08:00
IVUsers.cpp
IndirectCallPromotionAnalysis.cpp [Analysis] Remove unused system header includes 2020-11-22 10:32:37 +00:00
InlineAdvisor.cpp [llvm][inliner] Reuse the inliner pass to implement 'always inliner' 2020-11-30 12:03:39 -08:00
InlineCost.cpp [InlineCost] Implement cost-benefit-based inliner 2020-12-18 00:37:24 -08:00
InlineSizeEstimatorAnalysis.cpp [MLGO] Fix build break as result of new InstructionCost (D91174) 2020-12-11 20:28:39 -08:00
InstCount.cpp [NFC] Port InstCount pass to new pass manager 2020-08-21 12:39:42 +03:00
InstructionPrecedenceTracking.cpp [IPT] Don't use OrderedInstructions (NFC) 2020-04-20 18:25:31 +02:00
InstructionSimplify.cpp [InstSimplify] Don't miscompile `X == 0 ? abs(X) : -abs(X) --> -abs(X)` xform 2020-12-18 21:18:13 +03:00
Interval.cpp [Analysis/Interval] Remove isLoop (NFC) 2020-12-12 10:09:35 -08:00
IntervalPartition.cpp
LazyBlockFrequencyInfo.cpp
LazyBranchProbabilityInfo.cpp
LazyCallGraph.cpp [LazyCallGraph] Build SCCs of the reference graph in order 2020-11-02 13:22:42 -08:00
LazyValueInfo.cpp [Analysis] Use is_contained (NFC) 2020-12-11 21:19:31 -08:00
LegacyDivergenceAnalysis.cpp [DivergenceAnalysis] Use addRequiredTransitive 2020-11-13 14:40:00 +01:00
Lint.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
Loads.cpp Use deref facts derived from minimum object size of allocations 2020-12-03 15:01:14 -08:00
LoopAccessAnalysis.cpp [LAA] Relax restrictions on early exits in loop structure 2020-12-14 12:44:01 -08:00
LoopAnalysisManager.cpp [NFC] Reduce include files dependency. 2020-12-03 18:25:05 +03:00
LoopCacheAnalysis.cpp [LoopInfo] empty() -> isInnermost(), add isOutermost() 2020-09-22 23:28:51 +03:00
LoopInfo.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
LoopNestAnalysis.cpp [LoopNest] Handle loop-nest passes in LoopPassManager 2020-12-16 17:07:14 +00:00
LoopPass.cpp [Analysis] Use llvm::erase_value (NFC) 2020-12-14 22:40:13 -08:00
LoopUnrollAnalyzer.cpp ScalarEvolution.h - reduce LoopInfo.h include to forward declarations. NFC. 2020-06-17 15:48:23 +01:00
MLInlineAdvisor.cpp [llvm][inliner] Reuse the inliner pass to implement 'always inliner' 2020-11-30 12:03:39 -08:00
MemDepPrinter.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
MemDerefPrinter.cpp Port -print-memderefs to NPM 2020-11-23 11:56:22 -08:00
MemoryBuiltins.cpp Analysis: only query size of sized objects. 2020-10-14 12:16:05 +01:00
MemoryDependenceAnalysis.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
MemoryLocation.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
MemorySSA.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
MemorySSAUpdater.cpp [MemorySSA] Rename uses in blocks with Phis. 2020-09-16 17:24:17 -07:00
ModuleDebugInfoPrinter.cpp [NPM] Port module-debuginfo pass to the new pass manager 2020-10-19 14:31:17 -07:00
ModuleSummaryAnalysis.cpp [StackSafety] Use ValueInfo in ParamAccess::Call 2020-08-14 12:42:44 -07:00
MustExecute.cpp Port print-must-be-executed-contexts and print-mustexecute to NPM 2020-11-03 21:06:46 -08:00
ObjCARCAliasAnalysis.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
ObjCARCAnalysisUtils.cpp [NFC] Reduce include files dependency. 2020-12-03 18:25:05 +03:00
ObjCARCInstKind.cpp [Analysis/Transforms/Sanitizers] As part of using inclusive language 2020-06-20 00:42:26 -07:00
OptimizationRemarkEmitter.cpp [Remarks][2/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:50 -08:00
PHITransAddr.cpp
PhiValues.cpp [PhiValues] Use SetVector to avoid non-determinism 2020-10-23 20:14:02 +02:00
PostDominators.cpp
ProfileSummaryInfo.cpp [NFC] Change getEntryForPercentile to be a static function in ProfileSummaryBuilder. 2020-07-09 16:38:19 -07:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp RegionInfo.cpp - remove duplicate includes that already exist in RegionInfo.h. NFC. 2020-07-23 17:50:22 +01:00
RegionPass.cpp [NFC] Clean up always false variables 2020-10-21 10:54:55 -07:00
RegionPrinter.cpp
ReleaseModeModelRunner.cpp static const char *const foo => const char foo[] 2020-12-01 10:33:18 -08:00
ReplayInlineAdvisor.cpp [InlineAdvisor] New inliner advisor to replay inlining from optimization remarks 2020-08-15 20:17:21 -07:00
ScalarEvolution.cpp [SCEV] Add missing type check into getRangeForAffineNoSelfWrappingAR 2020-12-15 14:50:32 +07:00
ScalarEvolutionAliasAnalysis.cpp [AA] Split up LocationSize::unknown() 2020-11-26 18:39:55 +01:00
ScalarEvolutionDivision.cpp [SCEV] Generalize SCEVParameterRewriter to accept SCEV expression as target. 2020-09-18 10:05:02 +01:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
StackLifetime.cpp When dumping results of StackLifetime, it will print the following 2020-09-07 11:43:16 +08:00
StackSafetyAnalysis.cpp [Analysis] resolveAllCalls - fix use after std::move warning. NFCI. 2020-10-03 17:52:20 +01:00
StratifiedSets.h
SyncDependenceAnalysis.cpp [SDA] Fix -Wunused-function in -DLLVM_ENABLE_ASSERTIONS=off builds 2020-10-04 12:17:16 -07:00
SyntheticCountsUtils.cpp [CallSite removal] Remove unneeded includes of CallSite.h. NFC 2020-04-22 00:07:13 -07:00
TFUtils.cpp [NFC][TFUtils] also include output specs lookup logic in loadOutputSpecs 2020-11-18 21:20:21 -08:00
TargetLibraryInfo.cpp Initial support for vectorization using Libmvec (GLIBC vector math library) 2020-10-22 16:01:39 -04:00
TargetTransformInfo.cpp [TTI] Add supportsScalableVectors target hook 2020-12-18 10:37:01 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [NFC] Reduce include files dependency and AA header cleanup (part 2). 2020-12-17 14:04:48 +03:00
TypeMetadataUtils.cpp TypeMetadataUtils.h - reduce Instructions.h include to forward declaration. NFC. 2020-06-05 17:40:33 +01:00
VFABIDemangling.cpp [SVE] Make ElementCount members private 2020-08-28 14:43:53 +01:00
ValueLattice.cpp
ValueLatticeUtils.cpp [ValueLattice] Simplify canTrackGlobalVariableInterprocedurally (NFC). 2020-07-09 18:33:09 +01:00
ValueTracking.cpp Teach isKnownNonEqual how to recurse through invertible multiplies 2020-12-07 14:52:08 -08:00
VectorUtils.cpp [JumpThreading][VectorUtils] avoid infinite loop on unreachable IR 2020-12-02 13:39:33 -05:00

README.txt

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))

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