diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-02-18 23:33:05 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-18 23:33:05 +0000 |
commit | d8b4efcb6b4a3408da72e45b4e4225b751065ac9 (patch) | |
tree | 8a8f3bf8d8c89f055fa94b81f3be94b8c64c7dad /llvm/include | |
parent | 05709acba49a0ead78f33487ef377ff2ef376496 (diff) | |
download | bcm5719-llvm-d8b4efcb6b4a3408da72e45b4e4225b751065ac9.tar.gz bcm5719-llvm-d8b4efcb6b4a3408da72e45b4e4225b751065ac9.zip |
[CGP] form usub with overflow from sub+icmp
The motivating x86 cases for forming the intrinsic are shown in PR31754 and PR40487:
https://bugs.llvm.org/show_bug.cgi?id=31754
https://bugs.llvm.org/show_bug.cgi?id=40487
..and those are shown in the IR test file and x86 codegen file.
Matching the usubo pattern is harder than uaddo because we have 2 independent values rather than a def-use.
This adds a TLI hook that should preserve the existing behavior for uaddo formation, but disables usubo
formation by default. Only x86 overrides that setting for now although other targets will likely benefit
by forming usbuo too.
Differential Revision: https://reviews.llvm.org/D57789
llvm-svn: 354298
Diffstat (limited to 'llvm/include')
-rw-r--r-- | llvm/include/llvm/CodeGen/TargetLowering.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index 395207f3d3d..5e633fbb589 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -2439,6 +2439,23 @@ public: return false; } + /// Try to convert math with an overflow comparison into the corresponding DAG + /// node operation. Targets may want to override this independently of whether + /// the operation is legal/custom for the given type because it may obscure + /// matching of other patterns. + virtual bool shouldFormOverflowOp(unsigned Opcode, EVT VT) const { + // TODO: The default logic is inherited from code in CodeGenPrepare. + // The opcode should not make a difference by default? + if (Opcode != ISD::UADDO) + return false; + + // Allow the transform as long as we have an integer type that is not + // obviously illegal and unsupported. + if (VT.isVector()) + return false; + return VT.isSimple() || !isOperationExpand(Opcode, VT); + } + // Return true if it is profitable to use a scalar input to a BUILD_VECTOR // even if the vector itself has multiple uses. virtual bool aggressivelyPreferBuildVectorSources(EVT VecVT) const { |