forked from OSchip/llvm-project
0c1c70aef4
By enhancing value tracking, we allow an existing min/max canonicalization to kick in and improve codegen for several targets that have min/max instructions. Unfortunately, recognizing min/max in value tracking may cause us to hit a hack in InstCombiner::visitICmpInst() more often: http://lists.llvm.org/pipermail/llvm-dev/2017-January/109340.html ...but I'm hoping we can remove that soon. Correctness proofs based on Alive: Name: smaxmin Pre: C1 < C2 %cmp2 = icmp slt i8 %x, C2 %min = select i1 %cmp2, i8 %x, i8 C2 %cmp3 = icmp slt i8 %x, C1 %r = select i1 %cmp3, i8 C1, i8 %min => %cmp2 = icmp slt i8 %x, C2 %min = select i1 %cmp2, i8 %x, i8 C2 %cmp1 = icmp sgt i8 %min, C1 %r = select i1 %cmp1, i8 %min, i8 C1 Name: sminmax Pre: C1 > C2 %cmp2 = icmp sgt i8 %x, C2 %max = select i1 %cmp2, i8 %x, i8 C2 %cmp3 = icmp sgt i8 %x, C1 %r = select i1 %cmp3, i8 C1, i8 %max => %cmp2 = icmp sgt i8 %x, C2 %max = select i1 %cmp2, i8 %x, i8 C2 %cmp1 = icmp slt i8 %max, C1 %r = select i1 %cmp1, i8 %max, i8 C1 ---------------------------------------- Optimization: smaxmin Done: 1 Optimization is correct! ---------------------------------------- Optimization: sminmax Done: 1 Optimization is correct! Name: umaxmin Pre: C1 u< C2 %cmp2 = icmp ult i8 %x, C2 %min = select i1 %cmp2, i8 %x, i8 C2 %cmp3 = icmp ult i8 %x, C1 %r = select i1 %cmp3, i8 C1, i8 %min => %cmp2 = icmp ult i8 %x, C2 %min = select i1 %cmp2, i8 %x, i8 C2 %cmp1 = icmp ugt i8 %min, C1 %r = select i1 %cmp1, i8 %min, i8 C1 Name: uminmax Pre: C1 u> C2 %cmp2 = icmp ugt i8 %x, C2 %max = select i1 %cmp2, i8 %x, i8 C2 %cmp3 = icmp ugt i8 %x, C1 %r = select i1 %cmp3, i8 C1, i8 %max => %cmp2 = icmp ugt i8 %x, C2 %max = select i1 %cmp2, i8 %x, i8 C2 %cmp1 = icmp ult i8 %max, C1 %r = select i1 %cmp1, i8 %max, i8 C1 ---------------------------------------- Optimization: umaxmin Done: 1 Optimization is correct! ---------------------------------------- Optimization: uminmax Done: 1 Optimization is correct! llvm-svn: 292660 |
||
---|---|---|
.. | ||
ADCE | ||
AddDiscriminators | ||
AlignmentFromAssumptions | ||
ArgumentPromotion | ||
AtomicExpand | ||
BBVectorize | ||
BDCE | ||
BranchFolding | ||
CodeExtractor | ||
CodeGenPrepare | ||
ConstProp | ||
ConstantHoisting | ||
ConstantMerge | ||
Coroutines | ||
CorrelatedValuePropagation | ||
CountingFunctionInserter | ||
CrossDSOCFI | ||
DCE | ||
DeadArgElim | ||
DeadStoreElimination | ||
EarlyCSE | ||
EliminateAvailableExternally | ||
Float2Int | ||
ForcedFunctionAttrs | ||
FunctionAttrs | ||
FunctionImport | ||
GCOVProfiling | ||
GVN | ||
GVNHoist | ||
GlobalDCE | ||
GlobalMerge | ||
GlobalOpt | ||
GlobalSplit | ||
GuardWidening | ||
IPConstantProp | ||
IRCE | ||
IndVarSimplify | ||
InferFunctionAttrs | ||
Inline | ||
InstCombine | ||
InstMerge | ||
InstSimplify | ||
InterleavedAccess/X86 | ||
Internalize | ||
JumpThreading | ||
LCSSA | ||
LICM | ||
LoadCombine | ||
LoadStoreVectorizer | ||
LoopDataPrefetch | ||
LoopDeletion | ||
LoopDistribute | ||
LoopIdiom | ||
LoopInterchange | ||
LoopLoadElim | ||
LoopReroll | ||
LoopRotate | ||
LoopSimplify | ||
LoopSimplifyCFG | ||
LoopStrengthReduce | ||
LoopUnroll | ||
LoopUnswitch | ||
LoopVectorize | ||
LoopVersioning | ||
LoopVersioningLICM | ||
LowerAtomic | ||
LowerExpectIntrinsic | ||
LowerGuardIntrinsic | ||
LowerInvoke | ||
LowerSwitch | ||
LowerTypeTests | ||
Mem2Reg | ||
MemCpyOpt | ||
MergeFunc | ||
MetaRenamer | ||
NameAnonGlobals | ||
NaryReassociate | ||
NewGVN | ||
ObjCARC | ||
PGOProfile | ||
PartiallyInlineLibCalls | ||
PhaseOrdering | ||
PlaceSafepoints | ||
PreISelIntrinsicLowering | ||
PruneEH | ||
Reassociate | ||
Reg2Mem | ||
RewriteStatepointsForGC | ||
SCCP | ||
SLPVectorizer | ||
SROA | ||
SafeStack | ||
SampleProfile | ||
Scalarizer | ||
SeparateConstOffsetFromGEP | ||
SimplifyCFG | ||
Sink | ||
SpeculativeExecution | ||
StraightLineStrengthReduce | ||
StripDeadPrototypes | ||
StripSymbols | ||
StructurizeCFG | ||
TailCallElim | ||
ThinLTOBitcodeWriter | ||
Util | ||
WholeProgramDevirt |