diff options
| author | Sam Parker <sam.parker@arm.com> | 2018-09-17 13:57:39 +0000 | 
|---|---|---|
| committer | Sam Parker <sam.parker@arm.com> | 2018-09-17 13:57:39 +0000 | 
| commit | 481cdab9199e6459d074da14cf1818c40b9cec16 (patch) | |
| tree | db72095f3e5289721951e2675ac1958a3ddca226 /llvm/lib | |
| parent | a2fd56c3e45b3815e7254680bc2dc4c75885181c (diff) | |
| download | bcm5719-llvm-481cdab9199e6459d074da14cf1818c40b9cec16.tar.gz bcm5719-llvm-481cdab9199e6459d074da14cf1818c40b9cec16.zip | |
[ARM] Cleanup ARM CGP isSupportedValue
isSupportedValue explicitly checked and accepted many types of value,
primarily for debugging reasons. Remove most of these checks and do a
bit of refactoring now that the pass is more stable. This also enables
ZExts to be sources, but this has very little practical benefit at the
moment extend instructions will still be introduced.
Differential Revision: https://reviews.llvm.org/D52080
llvm-svn: 342395
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp | 61 | 
1 files changed, 19 insertions, 42 deletions
| diff --git a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp index a1241b7a1e2..826efe9f693 100644 --- a/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp +++ b/llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp @@ -165,6 +165,9 @@ static bool generateSignBits(Value *V) {    if (!isa<Instruction>(V))      return false; +  if (isa<SExtInst>(V)) +    return true; +    unsigned Opc = cast<Instruction>(V)->getOpcode();    return Opc == Instruction::AShr || Opc == Instruction::SDiv ||           Opc == Instruction::SRem; @@ -201,17 +204,10 @@ static bool isSupportedType(Value *V) {  static bool isSource(Value *V) {    if (!isa<IntegerType>(V->getType()))      return false; -  // TODO Allow zext to be sources. -  if (isa<Argument>(V)) -    return true; -  else if (isa<LoadInst>(V)) -    return true; -  else if (isa<BitCastInst>(V)) +  else if (isa<Argument>(V) || isa<LoadInst>(V) || isa<CallInst>(V))      return true; -  else if (auto *Call = dyn_cast<CallInst>(V)) -    return Call->hasRetAttr(Attribute::AttrKind::ZExt); -  else if (auto *Trunc = dyn_cast<TruncInst>(V)) -    return isSupportedType(Trunc); +  else if (isa<CastInst>(V)) +    return isSupportedType(V);    return false;  } @@ -526,31 +522,22 @@ void IRPromoter::Mutate(Type *OrigTy,  /// return value is zeroext. We don't allow opcodes that can introduce sign  /// bits.  bool ARMCodeGenPrepare::isSupportedValue(Value *V) { -  if (isa<ICmpInst>(V)) -    return true; +  if (generateSignBits(V)) +    return false; -  // Memory instructions -  if (isa<StoreInst>(V) || isa<GetElementPtrInst>(V)) -    return true; +  // Disallow for simplicity. +  if (isa<ConstantExpr>(V)) +    return false; -  // Branches and targets. -  if( isa<BranchInst>(V) || isa<SwitchInst>(V) || isa<BasicBlock>(V)) +  // Special case because they generate an i1, which we don't generally +  // support. +  if (isa<ICmpInst>(V))      return true; -  // Non-instruction values that we can handle. -  if ((isa<Constant>(V) && !isa<ConstantExpr>(V)) || isa<Argument>(V)) -    return isSupportedType(V); - -  if (isa<PHINode>(V) || isa<SelectInst>(V) || isa<ReturnInst>(V) || -      isa<LoadInst>(V)) -    return isSupportedType(V); - -  // Truncs can be either sources or sinks. -  if (auto *Trunc = dyn_cast<TruncInst>(V)) -    return isSupportedType(Trunc) || isSupportedType(Trunc->getOperand(0)); - -  if (isa<CastInst>(V) && !isa<SExtInst>(V)) -    return isSupportedType(cast<CastInst>(V)->getOperand(0)); +  // Both ZExts and Truncs can be either sources and sinks. BitCasts are also +  // sources and SExts are disallowed through their sign bit generation. +  if (auto *Cast = dyn_cast<CastInst>(V)) +    return isSupportedType(Cast) || isSupportedType(Cast->getOperand(0));    // Special cases for calls as we need to check for zeroext    // TODO We should accept calls even if they don't have zeroext, as they can @@ -559,17 +546,7 @@ bool ARMCodeGenPrepare::isSupportedValue(Value *V) {      return isSupportedType(Call) &&             Call->hasRetAttr(Attribute::AttrKind::ZExt); -  if (!isa<BinaryOperator>(V)) -    return false; - -  if (!isSupportedType(V)) -    return false; - -  if (generateSignBits(V)) { -    LLVM_DEBUG(dbgs() << "ARM CGP: No, instruction can generate sign bits.\n"); -    return false; -  } -  return true; +  return isSupportedType(V);  }  /// Check that the type of V would be promoted and that the original type is | 

