llvm-project/llvm/test/Transforms
Roman Lebedev 352fef3f11
[InstCombine] Negator - sink sinkable negations
Summary:
As we have discussed previously (e.g. in D63992 / D64090 / [[ https://bugs.llvm.org/show_bug.cgi?id=42457 | PR42457 ]]), `sub` instruction
can almost be considered non-canonical. While we do convert `sub %x, C` -> `add %x, -C`,
we sparsely do that for non-constants. But we should.

Here, i propose to interpret `sub %x, %y` as `add (sub 0, %y), %x` IFF the negation can be sinked into the `%y`

This has some potential to cause endless combine loops (either around PHI's, or if there are some opposite transforms).
For former there's `-instcombine-negator-max-depth` option to mitigate it, should this expose any such issues
For latter, if there are still any such opposing folds, we'd need to remove the colliding fold.
In any case, reproducers welcomed!

Reviewers: spatel, nikic, efriedma, xbolva00

Reviewed By: spatel

Subscribers: xbolva00, mgorny, hiraditya, reames, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68408
2020-04-21 22:00:23 +03:00
..
ADCE [ADCE] Fix incorrect reporting of CFG changes 2020-04-14 20:26:13 +07:00
AddDiscriminators Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
AggressiveInstCombine [AggressiveInstCombine] Add test with baseline CHECKs for aggressive inst combine for ICmp instruction. 2020-02-12 15:09:38 +02:00
AlignmentFromAssumptions [AlignmentFromAssumptions] Fix a SCEV assertion resulting from address space differences. 2020-03-29 01:26:31 -05:00
ArgumentPromotion [Attributor] Remove large and seemingly useless test 2020-04-15 21:26:36 -05:00
AtomicExpand [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
Attributor [Attributor] Partially disable three tests to unblock the windows bot 2020-04-20 21:11:02 -05:00
BDCE Clang-trunk Generates Wrong Debug values with -O1 2019-11-21 13:53:10 -08:00
BlockExtractor Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
BranchFolding
CallSiteSplitting [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
CalledValuePropagation
CanonicalizeAliases
CodeExtractor [CodeExtractor] Fix typo in check label to fix issue reported on D77354 2020-04-08 14:59:15 +01:00
CodeGenPrepare [SelectionDAGBuilder][CGP][X86] Move some of SDB's gather/scatter uniform base handling to CGP. 2020-04-16 17:49:22 -07:00
ConstProp [ConstProp] Add test for bitcast to gep fold; NFC 2020-03-04 18:27:20 +01:00
ConstantHoisting Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
ConstantMerge
Coroutines [Coroutines] Remove alignment check in shouldBeMustTail 2020-04-07 09:07:34 +08:00
CorrelatedValuePropagation [ConstantRange] Use APInt::or/APInt::and for single elements. 2020-04-01 09:50:24 +01:00
CrossDSOCFI
DCE [AssumeBundles] preserve knowledge in DCE 2020-04-14 12:48:15 +02:00
DeadArgElim [NFC] Fix trivial typos in comments 2020-01-06 10:50:26 +00:00
DeadStoreElimination [DSE,MSSA] Add use of alloca, to guard against removal in the future. 2020-04-15 15:23:43 +01:00
DivRemPairs [DivRemPairs] Freeze operands if they can be undef values 2020-03-25 03:46:14 +09:00
EarlyCSE [AssumeBundles] Preserve information in EarlyCSE 2020-03-31 17:47:04 +02:00
EliminateAvailableExternally
EntryExitInstrumenter [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
ExpandMemCmp [ExpandMemCmp] Allow overlaping loads in the zero-relational case. 2020-04-02 11:20:47 +02:00
FixIrreducible Introduce fix-irreducible pass 2020-04-15 15:05:51 +05:30
Float2Int
ForcedFunctionAttrs
FunctionAttrs [Attributor] Copy or port test cases related to Attributor to` Attributor` test folder 2019-12-02 15:36:29 +00:00
FunctionImport Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
GCOVProfiling Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
GVN [GVN] Fix VNCoercion for Scalable Vector. 2020-04-10 17:49:07 -07:00
GVNHoist Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
GVNSink Fix another instance where a variable was renamed in the generated LLVM IR. [NFC] 2020-03-23 22:53:29 -07:00
GlobalDCE [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables 2020-01-23 11:36:01 -08:00
GlobalMerge
GlobalOpt [GlobalOpt] Explicitly set alignment of bool load/store operations. 2020-04-12 16:03:12 -07:00
GlobalSplit [WPD/VFE] Always emit vcall_visibility metadata for -fwhole-program-vtables 2020-01-23 11:36:01 -08:00
GuardWidening [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
HardwareLoops Recommit "[HardwareLoops] Optimisation remarks" 2019-11-05 09:06:22 +00:00
HotColdSplit [HotColdSplit] Mark entire function cold when entry block is cold 2020-02-17 15:57:50 -08:00
IPConstantProp [SCCP] Do not mark unknown loads as overdefined. 2020-02-20 22:48:58 +01:00
IRCE [IRCE] Use SCEVExpander to modify loop bound 2020-02-06 12:44:43 +03:00
IndVarSimplify Revert "[SCEV] rewriteLoopExitValues(): even if have hard uses, still rewrite if cheap (PR44668)" 2020-04-03 20:15:04 +03:00
IndirectBrExpand
InferAddressSpaces
InferFunctionAttrs [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
Inline Revert "[InlineFunction] Update metadata on loads that are return values" 2020-04-17 17:23:00 -04:00
InstCombine [InstCombine] Negator - sink sinkable negations 2020-04-21 22:00:23 +03:00
InstMerge
InstNamer
InstSimplify [Analysis] recognize the 'null' pointer constant as not poison 2020-04-21 14:23:06 -04:00
InterleavedAccess [ARM] Disable VLD4 under MVE 2019-12-08 10:37:29 +00:00
Internalize Reland: Dead Virtual Function Elimination 2019-10-17 09:58:57 +00:00
JumpThreading Fix MSan false positive due to select folding. 2020-03-31 15:25:42 -07:00
LCSSA [SSAUpdater] Don't call ValueIsRAUWd upon single use replacement 2020-01-23 15:53:53 +07:00
LICM [LICM] Try to merge debug locations when sinking. 2020-04-15 12:29:34 -07:00
LoadStoreVectorizer AMDGPU: Fix broken check lines 2020-04-01 10:52:22 -07:00
LoopDataPrefetch
LoopDeletion
LoopDistribute
LoopFusion [LoopFusion] Move instructions from FC1.GuardBlock to FC0.GuardBlock and 2020-01-30 18:02:22 +00:00
LoopIdiom Require "target datalayout" to be at the beginning of an IR file. 2020-04-20 11:55:49 -07:00
LoopInstSimplify
LoopInterchange [llvm] Fix yet more missing FileCheck colons 2020-04-13 10:49:19 -06:00
LoopLoadElim [LoopLoadElim] Fix crash by always checking simplify form 2020-04-10 09:23:28 +07:00
LoopPredication [BasicBlock] fix looping in getPostdominatingDeoptimizeCall 2020-01-17 15:40:02 +03:00
LoopReroll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
LoopRotate [LoopRotate] Cleanup test checks to fix issue reported on D77354 2020-04-03 17:21:37 +01:00
LoopSimplify [LoopSimplify] Regenerate test checks; NFC 2020-01-11 11:02:24 +01:00
LoopSimplifyCFG
LoopStrengthReduce [LoopStrengthReduce] Fix test checks to fix issue reported on D77227 2020-04-03 18:10:33 +01:00
LoopTransformWarning
LoopUnroll [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
LoopUnrollAndJam [llvm] Make new pass manager's OptimizationLevel a class 2020-01-16 09:00:56 -08:00
LoopUnswitch
LoopVectorize Require "target datalayout" to be at the beginning of an IR file. 2020-04-20 11:55:49 -07:00
LoopVersioning
LoopVersioningLICM
LowerAtomic
LowerConstantIntrinsics Reapply r374743 with a fix for the ocaml binding 2019-10-14 16:15:14 +00:00
LowerExpectIntrinsic
LowerGuardIntrinsic
LowerInvoke
LowerMatrixIntrinsics [Matrix] Add option to use row-major matrix layout as default. 2020-04-06 10:00:56 +01:00
LowerSwitch
LowerTypeTests LowerTypeTests: Rename local functions to avoid collisions with identically named functions in ThinLTO modules. 2019-10-03 23:42:44 +00:00
LowerWidenableCondition
MakeGuardsExplicit
Mem2Reg
MemCpyOpt [ValueTracking] Fix usage of DataLayout::getTypeStoreSize() 2020-03-20 16:52:15 -07:00
MergeFunc [NewPM] Port MergeFunctions pass 2020-01-14 20:55:41 +01:00
MergeICmps Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
MetaRenamer
NameAnonGlobals
NaryReassociate
NewGVN Require "target datalayout" to be at the beginning of an IR file. 2020-04-20 11:55:49 -07:00
ObjCARC [ObjC][ARC] Don't remove autoreleaseRV/retainRV pairs if the call isn't 2020-03-13 13:52:14 -07:00
OpenMP [OpenMPOpt] Make the combination of `ident_t*` deterministic 2020-04-20 23:27:08 -05:00
PGOProfile [CallSite Removal] a CallBase is never an IndirectCall for isInlineAsm 2020-04-06 16:14:46 -07:00
PartiallyInlineLibCalls
PhaseOrdering [VectorCombine] transform bitcasted shuffle to wider elements 2020-04-19 08:24:38 -04:00
PlaceSafepoints
PreISelIntrinsicLowering [ObjC] Override TailCallKind when lowering objc intrinsics 2019-11-11 08:30:06 -08:00
PruneEH
Reassociate [Reassociate] add testcases for more than 1 pairs - NFC 2020-03-19 05:21:24 -04:00
Reg2Mem
RewriteStatepointsForGC [RS4GC] Handle uses of extractelement for conversion from vector to scalar base 2020-03-06 16:28:49 -05:00
SCCP [SCCP] Add additional tests for structs, conditional prop and widening. 2020-04-18 14:07:56 +01:00
SLPVectorizer Allow disabling of vectorization using internal options 2020-04-14 18:09:10 -07:00
SROA Make IRBuilder automatically set alignment on load/store/alloca. 2020-04-13 13:43:14 -07:00
SafeStack Require "target datalayout" to be at the beginning of an IR file. 2020-04-20 11:55:49 -07:00
SampleProfile [SampleFDO] Port MD5 name table support to extbinary format. 2020-03-30 22:07:08 -07:00
ScalarizeMaskedMemIntrin/X86
Scalarizer [Scalarizer] Fix a non-deterministic scatter order problem 2020-04-20 16:05:33 +02:00
SeparateConstOffsetFromGEP Fix PR45371: SeparateConstOffsetFromGEP clean up bookkeeping 2020-04-01 12:38:15 -06:00
SimpleLoopUnswitch Revert "[SimpleLoopUnswitch] Fix introduction of UB when hoisted condition may be undef or poison" 2020-02-28 11:10:46 +09:00
SimplifyCFG Fix lifetime call in landingpad blocking Simplifycfg pass 2020-04-09 13:07:32 -07:00
Sink
SpeculateAroundPHIs
SpeculativeExecution
StraightLineStrengthReduce Migrate function attribute "no-frame-pointer-elim"="false" to "frame-pointer"="none" as cleanups after D56351 2019-12-24 16:27:51 -08:00
StripDeadPrototypes
StripSymbols
StructurizeCFG Introduce fix-irreducible pass 2020-04-15 15:05:51 +05:30
SyntheticCountsPropagation
TailCallElim
ThinLTOBitcodeWriter ThinLTOBitcodeWriter: drop dso_local when a GlobalVariable is converted to a declaration 2020-03-05 18:09:33 -08:00
TypePromotion/ARM Revert "[ARM][TypePromotion] Enable by default" 2019-12-22 11:27:11 -08:00
UnifyLoopExits Introduce unify-loop-exits pass. 2020-03-30 13:23:56 -04:00
UniqueInternalLinkageNames New pass to make internal linkage symbol names unique. 2020-04-20 15:05:22 -07:00
Util Add option to limit Debugify to locations (omitting variables) 2020-04-06 15:04:55 -07:00
VectorCombine/X86 [VectorCombine] transform bitcasted shuffle to wider elements 2020-04-19 08:24:38 -04:00
WholeProgramDevirt [WPD] Avoid noalias assumptions in unique return value optimization 2020-04-16 14:49:51 -07:00