diff options
author | Craig Topper <craig.topper@intel.com> | 2019-08-25 05:22:40 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-08-25 05:22:40 +0000 |
commit | 1abe162a9a83e5aef24aca1e267818d5b6e65e90 (patch) | |
tree | 16bc7018d47677b69099c4b126951895f361f536 /llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | |
parent | 6e2776c9c4045e0a40c3d260aafa7856701607d8 (diff) | |
download | bcm5719-llvm-1abe162a9a83e5aef24aca1e267818d5b6e65e90.tar.gz bcm5719-llvm-1abe162a9a83e5aef24aca1e267818d5b6e65e90.zip |
[X86] Teach -Os immediate sharing code to not count constant uses that will become INC/DEC.
INC/DEC don't use an immediate so we don't need to count it. We
also shouldn't use the custom isel for it.
Fixes PR42998.
llvm-svn: 369863
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelDAGToDAG.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp index 46886419421..e0a462471a7 100644 --- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -362,6 +362,11 @@ namespace { if (User->getNumOperands() != 2) continue; + // If this can match to INC/DEC, don't count it as a use. + if (User->getOpcode() == ISD::ADD && + (isOneConstant(SDValue(N, 0)) || isAllOnesConstant(SDValue(N, 0)))) + continue; + // Immediates that are used for offsets as part of stack // manipulation should be left alone. These are typically // used to indicate SP offsets for argument passing and @@ -4369,6 +4374,10 @@ void X86DAGToDAGISel::Select(SDNode *Node) { if (!isInt<8>(Val) && !isInt<32>(Val)) break; + // If this can match to INC/DEC, let it go. + if (Opcode == ISD::ADD && (Val == 1 || Val == -1)) + break; + // Check if we should avoid folding this immediate. if (!shouldAvoidImmediateInstFormsForSize(N1.getNode())) break; |