1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/lib/Analysis
Sanjay Patel 988613b6b6 [ValueTracking] fix maxnum miscompile for cannotBeOrderedLessThanZero (PR37776)
This adds the NAN checks suggested in PR37776:
https://bugs.llvm.org/show_bug.cgi?id=37776

If both operands to maxnum are NAN, that should get constant folded, so we don't 
have to handle that case. This is the same assumption as other FP ops in this
function. Returning 'false' is always conservatively correct.

Copying from the bug report:

Currently, we have this for "when is cannotBeOrderedLessThanZero 
(mustBePositiveOrNaN) true for maxnum":
               L
        -------------------
        | Pos | Neg | NaN |
   ------------------------
   |Pos |  x  |  x  |  x  |
   ------------------------
 R |Neg |  x  |     |  x  |
   ------------------------
   |NaN |  x  |  x  |  x  |
   ------------------------


The cases with (Neg & NaN) are wrong. We should have:

                L
        -------------------
        | Pos | Neg | NaN |
   ------------------------
   |Pos |  x  |  x  |  x  |
   ------------------------
 R |Neg |  x  |     |     |
   ------------------------
   |NaN |  x  |     |  x  |
   ------------------------

Differential Revision: https://reviews.llvm.org/D50081

llvm-svn: 338716
2018-08-02 13:46:20 +00:00
..
AliasAnalysis.cpp [MSSA] Print more optimization information 2018-06-14 19:55:53 +00:00
AliasAnalysisEvaluator.cpp [MSSA] Print more optimization information 2018-06-14 19:55:53 +00:00
AliasAnalysisSummary.cpp
AliasAnalysisSummary.h Revert r332657: "[AA] cfl-anders-aa with field sensitivity" 2018-05-17 21:56:39 +00:00
AliasSetTracker.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
Analysis.cpp Add a PhiValuesAnalysis pass to calculate the underlying values of phis 2018-06-28 14:13:06 +00:00
AssumptionCache.cpp
BasicAliasAnalysis.cpp [BasicAA] Use PhiValuesAnalysis if available when handling phi alias 2018-07-30 11:52:08 +00:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
BranchProbabilityInfo.cpp [BPI] Remove unnecessary std::list 2018-06-15 21:06:43 +00:00
CallGraph.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
CallGraphSCCPass.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
CallPrinter.cpp Revert "Extend CFGPrinter and CallPrinter with Heat Colors" 2018-06-29 17:48:58 +00:00
CaptureTracking.cpp Fix aliasing of launder.invariant.group 2018-05-23 09:16:44 +00:00
CFG.cpp
CFGPrinter.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
CFLAndersAliasAnalysis.cpp Replace AA's uses of uint64_t with LocationSize; NFC. 2018-05-25 21:16:58 +00:00
CFLGraph.h [CFLAA] Reflow comments; NFC 2018-05-26 02:17:43 +00:00
CFLSteensAliasAnalysis.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
CGSCCPassManager.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
CMakeLists.txt Revert "Extend CFGPrinter and CallPrinter with Heat Colors" 2018-06-29 17:48:58 +00:00
CmpInstAnalysis.cpp
CodeMetrics.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
ConstantFolding.cpp ConstantFolding: Avoid a crash. 2018-07-23 21:20:00 +00:00
CostModel.cpp
Delinearization.cpp
DemandedBits.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
DependenceAnalysis.cpp [DA] Delinearise AddRecs if we can prove they don't wrap 2018-06-25 15:13:26 +00:00
DivergenceAnalysis.cpp DivergenceAnalysis: added debug output 2018-07-13 13:13:30 +00:00
DominanceFrontier.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
DomPrinter.cpp Revert "Extend CFGPrinter and CallPrinter with Heat Colors" 2018-06-29 17:48:58 +00:00
EHPersonalities.cpp [WebAssembly] Add Wasm personality and isScopedEHPersonality() 2018-05-17 20:52:03 +00:00
GlobalsModRef.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
IndirectCallPromotionAnalysis.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
InlineCost.cpp Revert "Enrich inline messages", tests fail 2018-08-01 08:02:40 +00:00
InstCount.cpp
InstructionSimplify.cpp [InstSimplify] move minnum/maxnum with same arg fold from instcombine 2018-08-01 23:05:55 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp [IDF] Enforce the returned blocks to be sorted. 2018-05-12 01:44:32 +00:00
IVUsers.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
LazyBlockFrequencyInfo.cpp Require DominatorTree when requiring/preserving LoopInfo in the old pass manager 2018-05-17 09:05:40 +00:00
LazyBranchProbabilityInfo.cpp Require DominatorTree when requiring/preserving LoopInfo in the old pass manager 2018-05-17 09:05:40 +00:00
LazyCallGraph.cpp [STLExtras] Add size() for ranges, and remove distance() 2018-05-16 23:20:42 +00:00
LazyValueInfo.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
Lint.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
LLVMBuild.txt
Loads.cpp Fix aliasing of launder.invariant.group 2018-05-23 09:16:44 +00:00
LoopAccessAnalysis.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
LoopAnalysisManager.cpp
LoopInfo.cpp [LoopInfo] Port loop exit interfaces from Loop to LoopBase 2018-07-09 17:52:49 +00:00
LoopPass.cpp [ORE] Move loop invariant ORE checks outside the PM loop. 2018-07-22 05:27:41 +00:00
LoopUnrollAnalyzer.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
MemDepPrinter.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
MemDerefPrinter.cpp
MemoryBuiltins.cpp Make llvm.objectsize more conservative with null 2018-07-09 22:21:16 +00:00
MemoryDependenceAnalysis.cpp [MemDep] Use PhiValuesAnalysis to improve alias analysis results 2018-07-31 14:19:29 +00:00
MemoryLocation.cpp [DSE] Teach the pass that atomic memory intrinsics are stores. 2018-04-23 19:06:49 +00:00
MemorySSA.cpp [MemorySSA] Add APIs to move memory accesses between blocks, following CFG changes. 2018-07-11 22:11:46 +00:00
MemorySSAUpdater.cpp [MemorySSAUpdater] Update Phi operands after trivial Phi elimination 2018-07-23 10:56:30 +00:00
ModuleDebugInfoPrinter.cpp
ModuleSummaryAnalysis.cpp [ThinLTO] Add string saver onto index for value names 2018-06-26 02:29:08 +00:00
MustExecute.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
ObjCARCAliasAnalysis.cpp
ObjCARCAnalysisUtils.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
ObjCARCInstKind.cpp [DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label. 2018-05-09 02:40:45 +00:00
OptimizationRemarkEmitter.cpp
OrderedBasicBlock.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
PHITransAddr.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
PhiValues.cpp Add a PhiValuesAnalysis pass to calculate the underlying values of phis 2018-06-28 14:13:06 +00:00
PostDominators.cpp [Dominators] Add PDT constructor from Function 2018-05-23 17:29:21 +00:00
ProfileSummaryInfo.cpp [SampleFDO] Don't treat warm callsite with inline instance in the profile as cold 2018-05-10 23:02:27 +00:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp Test commit, fix a minor typo. 2018-07-22 20:04:42 +00:00
RegionPass.cpp Rename DEBUG macro to LLVM_DEBUG. 2018-05-14 12:53:11 +00:00
RegionPrinter.cpp Revert "Extend CFGPrinter and CallPrinter with Heat Colors" 2018-06-29 17:48:58 +00:00
ScalarEvolution.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp [SCEV] Don't expand Wrap predicate using inttoptr in ni addrspaces 2018-07-26 21:55:06 +00:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp
StratifiedSets.h Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
SyntheticCountsUtils.cpp
TargetLibraryInfo.cpp Add Triple::isMIPS()/isMIPS32()/isMIPS64(). NFC 2018-06-25 16:49:20 +00:00
TargetTransformInfo.cpp Remove trailing space 2018-07-30 19:41:25 +00:00
Trace.cpp IWYU for llvm-config.h in llvm, additions. 2018-04-30 14:59:11 +00:00
TypeBasedAliasAnalysis.cpp
TypeMetadataUtils.cpp
ValueLattice.cpp
ValueLatticeUtils.cpp
ValueTracking.cpp [ValueTracking] fix maxnum miscompile for cannotBeOrderedLessThanZero (PR37776) 2018-08-02 13:46:20 +00:00
VectorUtils.cpp Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +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))

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