1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/lib/Analysis
Renato Golin bf4b959200 [ARM] Adding IEEE-754 SIMD detection to loop vectorizer
Some SIMD implementations are not IEEE-754 compliant, for example ARM's NEON.

This patch teaches the loop vectorizer to only allow transformations of loops
that either contain no floating-point operations or have enough allowance
flags supporting lack of precision (ex. -ffast-math, Darwin).

For that, the target description now has a method which tells us if the
vectorizer is allowed to handle FP math without falling into unsafe
representations, plus a check on every FP instruction in the candidate loop
to check for the safety flags.

This commit makes LLVM behave like GCC with respect to ARM NEON support, but
it stops short of fixing the underlying problem: sub-normals. Neither GCC
nor LLVM have a flag for allowing sub-normal operations. Before this patch,
GCC only allows it using unsafe-math flags and LLVM allows it by default with
no way to turn it off (short of not using NEON at all).

As a first step, we push this change to make it safe and in sync with GCC.
The second step is to discuss a new sub-normal's flag on both communitues
and come up with a common solution. The third step is to improve the FastMath
flags in LLVM to encode sub-normals and use those flags to restrict NEON FP.

Fixes PR16275.

llvm-svn: 266363
2016-04-14 20:42:18 +00:00
..
AliasAnalysis.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
AliasAnalysisEvaluator.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
AliasSetTracker.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
Analysis.cpp [ThinLTO] Move summary computation from BitcodeWriter to new pass 2016-04-11 13:58:45 +00:00
AssumptionCache.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
BasicAliasAnalysis.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
BlockFrequencyInfo.cpp Add getBlockProfileCount method to BlockFrequencyInfo 2016-03-23 18:18:26 +00:00
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp Const correctness for BranchProbabilityInfo (NFC) 2016-04-07 21:59:28 +00:00
CallGraph.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
CallGraphSCCPass.cpp
CallPrinter.cpp [CG] Rename the DOT printing pass to actually reference "DOT". 2016-03-10 11:04:40 +00:00
CaptureTracking.cpp
CFG.cpp
CFGPrinter.cpp
CFLAliasAnalysis.cpp [CFLAA] Fix up code style a bit. NFC. 2016-04-13 23:27:37 +00:00
CGSCCPassManager.cpp [PM] Implement the final conclusion as to how the analysis IDs should 2016-03-11 10:22:49 +00:00
CMakeLists.txt [ThinLTO] Move summary computation from BitcodeWriter to new pass 2016-04-11 13:58:45 +00:00
CodeMetrics.cpp use range-based for loop; NFCI 2016-03-08 20:53:48 +00:00
ConstantFolding.cpp Propagate Undef in llvm.cos Intrinsic 2016-04-08 18:21:11 +00:00
CostModel.cpp [CodeGen] Teach LLVM how to lower @llvm.{min,max}num to {MIN,MAX}NAN 2016-04-14 07:13:24 +00:00
Delinearization.cpp
DemandedBits.cpp
DependenceAnalysis.cpp [DependenceAnalysis] Check if result of getConstantPart is null 2016-04-04 18:13:18 +00:00
DivergenceAnalysis.cpp [DivergenceAnalysis] Treat PHI with incoming undef as constant 2016-04-14 17:42:47 +00:00
DominanceFrontier.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
DomPrinter.cpp
EHPersonalities.cpp Add Rust's personality function to the list of known personality functions 2016-03-15 20:35:45 +00:00
GlobalsModRef.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
InlineCost.cpp Return immediately from analyzeCall if analyzeBlock returns false. 2016-04-13 21:20:22 +00:00
InstCount.cpp
InstructionSimplify.cpp [InstCombine] We folded an fcmp to an i1 instead of a vector of i1 2016-04-13 06:55:52 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp
IVUsers.cpp
LazyCallGraph.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
LazyValueInfo.cpp [LVI] Fix a bug which prevented use of !range metadata within a query 2016-03-04 22:27:39 +00:00
Lint.cpp
LLVMBuild.txt
Loads.cpp Don't IPO over functions that can be de-refined 2016-04-08 00:48:30 +00:00
LoopAccessAnalysis.cpp [SCEV][LAA] Add tests for SCEV expression transformations performed during LAA 2016-04-14 16:08:45 +00:00
LoopInfo.cpp IR: Reserve an MDKind for !llvm.loop; NFC 2016-03-25 00:35:38 +00:00
LoopPass.cpp
LoopPassManager.cpp [PM] Implement the final conclusion as to how the analysis IDs should 2016-03-11 10:22:49 +00:00
LoopUnrollAnalyzer.cpp
MemDepPrinter.cpp [PM] Port memdep to the new pass manager. 2016-03-10 00:55:30 +00:00
MemDerefPrinter.cpp
MemoryBuiltins.cpp Calculate __builtin_object_size when pointer depends on a condition 2016-04-13 12:25:25 +00:00
MemoryDependenceAnalysis.cpp NFC: make AtomicOrdering an enum class 2016-04-06 21:19:33 +00:00
MemoryLocation.cpp
ModuleDebugInfoPrinter.cpp
ModuleSummaryAnalysis.cpp [ThinLTO] Move summary computation from BitcodeWriter to new pass 2016-04-11 13:58:45 +00:00
ObjCARCAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp
OrderedBasicBlock.cpp
PHITransAddr.cpp
PostDominators.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp [SCEV][LAA] Add tests for SCEV expression transformations performed during LAA 2016-04-14 16:08:45 +00:00
ScalarEvolutionAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
ScalarEvolutionExpander.cpp Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV 2016-04-08 14:29:09 +00:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
SparsePropagation.cpp
StratifiedSets.h [CFLAA] Fix up code style a bit. NFC. 2016-04-13 23:27:37 +00:00
TargetLibraryInfo.cpp [NVPTX] Infer __nvvm_reflect as nounwind, readnone 2016-03-31 21:29:57 +00:00
TargetTransformInfo.cpp [ARM] Adding IEEE-754 SIMD detection to loop vectorizer 2016-04-14 20:42:18 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [PM] Make the AnalysisManager parameter to run methods a reference. 2016-03-11 11:05:24 +00:00
ValueTracking.cpp Simplify strlen to a subtraction for certain cases. 2016-04-13 14:31:06 +00:00
VectorUtils.cpp [InstCombine] We folded an fcmp to an i1 instead of a vector of i1 2016-04-13 06:55:52 +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))

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