diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-02-03 17:53:09 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-03 17:53:09 +0000 |
commit | 84ceae6048cbfc5141a36c369eae621b4fb4d613 (patch) | |
tree | 3bb2500c8d07a61ee29e8aaa1bd5ae7eb6620d97 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | e2469b11a58890d1e79ed4df9bb266c4eedb05e6 (diff) | |
download | llvm-84ceae6048cbfc5141a36c369eae621b4fb4d613.zip llvm-84ceae6048cbfc5141a36c369eae621b4fb4d613.tar.gz llvm-84ceae6048cbfc5141a36c369eae621b4fb4d613.tar.bz2 |
[CGP] adjust target constraints for forming uaddo
There are 2 changes visible here:
1. There's no reason to limit this transform based on number
of condition registers. That diff allows PPC to produce
slightly better (dot-instructions should be generally good)
code.
Note: someone that cares about PPC codegen might want to
look closer at that output because it seems like we could
still improve this.
2. We (probably?) should not bother trying to form uaddo (or
other overflow ops) when there's no target support for such
an op. This goes beyond checking whether the op is expanded
because both PPC and AArch64 show better codegen for standard
types regardless of whether the op is legal/custom.
llvm-svn: 353001
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 792e4a5..bcb899a 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1149,20 +1149,22 @@ static bool OptimizeNoopCopyExpression(CastInst *CI, const TargetLowering &TLI, /// Try to combine the compare into a call to the llvm.uadd.with.overflow /// intrinsic. Return true if any changes were made. -static bool combineToUAddWithOverflow(CmpInst *Cmp, const TargetLowering &TLI) { - // TODO: Why is this transform limited by this condition? - if (TLI.hasMultipleConditionRegisters()) - return false; - +static bool combineToUAddWithOverflow(CmpInst *Cmp, const TargetLowering &TLI, + const DataLayout &DL) { Value *A, *B; Instruction *AddI; if (!match(Cmp, m_UAddWithOverflow(m_Value(A), m_Value(B), m_Instruction(AddI)))) return false; + // Allow the transform as long as we have an integer type that is not + // obviously illegal and unsupported. Type *Ty = AddI->getType(); if (!isa<IntegerType>(Ty)) return false; + EVT CodegenVT = TLI.getValueType(DL, Ty); + if (!CodegenVT.isSimple() && TLI.isOperationExpand(ISD::UADDO, CodegenVT)) + return false; // We don't want to move around uses of condition values this late, so we we // check if it is legal to create the call to the intrinsic in the basic @@ -1263,11 +1265,12 @@ static bool sinkCmpExpression(CmpInst *Cmp, const TargetLowering &TLI) { return MadeChange; } -static bool optimizeCmpExpression(CmpInst *Cmp, const TargetLowering &TLI) { +static bool optimizeCmpExpression(CmpInst *Cmp, const TargetLowering &TLI, + const DataLayout &DL) { if (sinkCmpExpression(Cmp, TLI)) return true; - if (combineToUAddWithOverflow(Cmp, TLI)) + if (combineToUAddWithOverflow(Cmp, TLI, DL)) return true; return false; @@ -6714,7 +6717,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, bool &ModifiedDT) { } if (CmpInst *CI = dyn_cast<CmpInst>(I)) - if (TLI && optimizeCmpExpression(CI, *TLI)) + if (TLI && optimizeCmpExpression(CI, *TLI, *DL)) return true; if (LoadInst *LI = dyn_cast<LoadInst>(I)) { |