Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 1 | //===-- AArch64TargetTransformInfo.cpp - AArch64 specific TTI pass --------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | /// \file |
| 10 | /// This file implements a TargetTransformInfo analysis pass specific to the |
| 11 | /// AArch64 target machine. It uses the target's detailed information to provide |
| 12 | /// more precise answers to certain TTI queries, while letting the target |
| 13 | /// independent and default TTI implementations handle the rest. |
| 14 | /// |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
| 17 | #include "AArch64.h" |
| 18 | #include "AArch64TargetMachine.h" |
| 19 | #include "MCTargetDesc/AArch64AddressingModes.h" |
| 20 | #include "llvm/Analysis/TargetTransformInfo.h" |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 21 | #include "llvm/CodeGen/BasicTTIImpl.h" |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 22 | #include "llvm/Support/Debug.h" |
| 23 | #include "llvm/Target/CostTable.h" |
| 24 | #include "llvm/Target/TargetLowering.h" |
| 25 | #include <algorithm> |
| 26 | using namespace llvm; |
| 27 | |
| 28 | #define DEBUG_TYPE "aarch64tti" |
| 29 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 30 | namespace { |
| 31 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 32 | class AArch64TTIImpl : public BasicTTIImplBase<AArch64TTIImpl> { |
| 33 | typedef BasicTTIImplBase<AArch64TTIImpl> BaseT; |
| 34 | typedef TargetTransformInfo TTI; |
| 35 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 36 | const AArch64Subtarget *ST; |
| 37 | const AArch64TargetLowering *TLI; |
| 38 | |
| 39 | /// Estimate the overhead of scalarizing an instruction. Insert and Extract |
| 40 | /// are set if the result needs to be inserted and/or extracted from vectors. |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 41 | unsigned getScalarizationOverhead(Type *Ty, bool Insert, bool Extract); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 42 | |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 43 | enum MemIntrinsicType { |
| 44 | VECTOR_LDST_TWO_ELEMENTS, |
| 45 | VECTOR_LDST_THREE_ELEMENTS, |
| 46 | VECTOR_LDST_FOUR_ELEMENTS |
| 47 | }; |
| 48 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 49 | public: |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 50 | explicit AArch64TTIImpl(const AArch64TargetMachine *TM = nullptr) |
| 51 | : BaseT(TM), ST(TM ? TM->getSubtargetImpl() : nullptr), |
| 52 | TLI(ST ? ST->getTargetLowering() : nullptr) {} |
| 53 | |
| 54 | // Provide value semantics. MSVC requires that we spell all of these out. |
| 55 | AArch64TTIImpl(const AArch64TTIImpl &Arg) |
| 56 | : BaseT(static_cast<const BaseT &>(Arg)), ST(Arg.ST), TLI(Arg.TLI) {} |
| 57 | AArch64TTIImpl(AArch64TTIImpl &&Arg) |
| 58 | : BaseT(std::move(static_cast<BaseT &>(Arg))), ST(std::move(Arg.ST)), |
| 59 | TLI(std::move(Arg.TLI)) {} |
| 60 | AArch64TTIImpl &operator=(const AArch64TTIImpl &RHS) { |
| 61 | BaseT::operator=(static_cast<const BaseT &>(RHS)); |
| 62 | ST = RHS.ST; |
| 63 | TLI = RHS.TLI; |
| 64 | return *this; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 65 | } |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 66 | AArch64TTIImpl &operator=(AArch64TTIImpl &&RHS) { |
| 67 | BaseT::operator=(std::move(static_cast<BaseT &>(RHS))); |
| 68 | ST = std::move(RHS.ST); |
| 69 | TLI = std::move(RHS.TLI); |
| 70 | return *this; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | /// \name Scalar TTI Implementations |
| 74 | /// @{ |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 75 | |
| 76 | using BaseT::getIntImmCost; |
| 77 | unsigned getIntImmCost(int64_t Val); |
| 78 | unsigned getIntImmCost(const APInt &Imm, Type *Ty); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 79 | unsigned getIntImmCost(unsigned Opcode, unsigned Idx, const APInt &Imm, |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 80 | Type *Ty); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 81 | unsigned getIntImmCost(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 82 | Type *Ty); |
| 83 | TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 84 | |
| 85 | /// @} |
| 86 | |
| 87 | /// \name Vector TTI Implementations |
| 88 | /// @{ |
| 89 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 90 | unsigned getNumberOfRegisters(bool Vector) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 91 | if (Vector) { |
| 92 | if (ST->hasNEON()) |
| 93 | return 32; |
| 94 | return 0; |
| 95 | } |
| 96 | return 31; |
| 97 | } |
| 98 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 99 | unsigned getRegisterBitWidth(bool Vector) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 100 | if (Vector) { |
| 101 | if (ST->hasNEON()) |
| 102 | return 128; |
| 103 | return 0; |
| 104 | } |
| 105 | return 64; |
| 106 | } |
| 107 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 108 | unsigned getMaxInterleaveFactor(); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 109 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 110 | unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 111 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 112 | unsigned getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 113 | |
Karthik Bhat | 7f33ff7 | 2014-08-25 04:56:54 +0000 | [diff] [blame] | 114 | unsigned getArithmeticInstrCost( |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 115 | unsigned Opcode, Type *Ty, |
| 116 | TTI::OperandValueKind Opd1Info = TTI::OK_AnyValue, |
| 117 | TTI::OperandValueKind Opd2Info = TTI::OK_AnyValue, |
| 118 | TTI::OperandValueProperties Opd1PropInfo = TTI::OP_None, |
| 119 | TTI::OperandValueProperties Opd2PropInfo = TTI::OP_None); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 120 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 121 | unsigned getAddressComputationCost(Type *Ty, bool IsComplex); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 122 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 123 | unsigned getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 124 | |
| 125 | unsigned getMemoryOpCost(unsigned Opcode, Type *Src, unsigned Alignment, |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 126 | unsigned AddressSpace); |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame] | 127 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 128 | unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys); |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame] | 129 | |
Kevin Qin | 72a799a | 2014-10-09 10:13:27 +0000 | [diff] [blame] | 130 | void getUnrollingPreferences(const Function *F, Loop *L, |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 131 | TTI::UnrollingPreferences &UP); |
Kevin Qin | 72a799a | 2014-10-09 10:13:27 +0000 | [diff] [blame] | 132 | |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 133 | Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 134 | Type *ExpectedType); |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 135 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 136 | bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info); |
Kevin Qin | 72a799a | 2014-10-09 10:13:27 +0000 | [diff] [blame] | 137 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 138 | /// @} |
| 139 | }; |
| 140 | |
| 141 | } // end anonymous namespace |
| 142 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 143 | ImmutablePass * |
| 144 | llvm::createAArch64TargetTransformInfoPass(const AArch64TargetMachine *TM) { |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 145 | return new TargetTransformInfoWrapperPass(AArch64TTIImpl(TM)); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /// \brief Calculate the cost of materializing a 64-bit value. This helper |
| 149 | /// method might only calculate a fraction of a larger immediate. Therefore it |
| 150 | /// is valid to return a cost of ZERO. |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 151 | unsigned AArch64TTIImpl::getIntImmCost(int64_t Val) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 152 | // Check if the immediate can be encoded within an instruction. |
| 153 | if (Val == 0 || AArch64_AM::isLogicalImmediate(Val, 64)) |
| 154 | return 0; |
| 155 | |
| 156 | if (Val < 0) |
| 157 | Val = ~Val; |
| 158 | |
| 159 | // Calculate how many moves we will need to materialize this constant. |
| 160 | unsigned LZ = countLeadingZeros((uint64_t)Val); |
| 161 | return (64 - LZ + 15) / 16; |
| 162 | } |
| 163 | |
| 164 | /// \brief Calculate the cost of materializing the given constant. |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 165 | unsigned AArch64TTIImpl::getIntImmCost(const APInt &Imm, Type *Ty) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 166 | assert(Ty->isIntegerTy()); |
| 167 | |
| 168 | unsigned BitSize = Ty->getPrimitiveSizeInBits(); |
| 169 | if (BitSize == 0) |
| 170 | return ~0U; |
| 171 | |
| 172 | // Sign-extend all constants to a multiple of 64-bit. |
| 173 | APInt ImmVal = Imm; |
| 174 | if (BitSize & 0x3f) |
| 175 | ImmVal = Imm.sext((BitSize + 63) & ~0x3fU); |
| 176 | |
| 177 | // Split the constant into 64-bit chunks and calculate the cost for each |
| 178 | // chunk. |
| 179 | unsigned Cost = 0; |
| 180 | for (unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) { |
| 181 | APInt Tmp = ImmVal.ashr(ShiftVal).sextOrTrunc(64); |
| 182 | int64_t Val = Tmp.getSExtValue(); |
| 183 | Cost += getIntImmCost(Val); |
| 184 | } |
| 185 | // We need at least one instruction to materialze the constant. |
| 186 | return std::max(1U, Cost); |
| 187 | } |
| 188 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 189 | unsigned AArch64TTIImpl::getIntImmCost(unsigned Opcode, unsigned Idx, |
| 190 | const APInt &Imm, Type *Ty) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 191 | assert(Ty->isIntegerTy()); |
| 192 | |
| 193 | unsigned BitSize = Ty->getPrimitiveSizeInBits(); |
| 194 | // There is no cost model for constants with a bit size of 0. Return TCC_Free |
| 195 | // here, so that constant hoisting will ignore this constant. |
| 196 | if (BitSize == 0) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 197 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 198 | |
| 199 | unsigned ImmIdx = ~0U; |
| 200 | switch (Opcode) { |
| 201 | default: |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 202 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 203 | case Instruction::GetElementPtr: |
| 204 | // Always hoist the base address of a GetElementPtr. |
| 205 | if (Idx == 0) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 206 | return 2 * TTI::TCC_Basic; |
| 207 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 208 | case Instruction::Store: |
| 209 | ImmIdx = 0; |
| 210 | break; |
| 211 | case Instruction::Add: |
| 212 | case Instruction::Sub: |
| 213 | case Instruction::Mul: |
| 214 | case Instruction::UDiv: |
| 215 | case Instruction::SDiv: |
| 216 | case Instruction::URem: |
| 217 | case Instruction::SRem: |
| 218 | case Instruction::And: |
| 219 | case Instruction::Or: |
| 220 | case Instruction::Xor: |
| 221 | case Instruction::ICmp: |
| 222 | ImmIdx = 1; |
| 223 | break; |
| 224 | // Always return TCC_Free for the shift value of a shift instruction. |
| 225 | case Instruction::Shl: |
| 226 | case Instruction::LShr: |
| 227 | case Instruction::AShr: |
| 228 | if (Idx == 1) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 229 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 230 | break; |
| 231 | case Instruction::Trunc: |
| 232 | case Instruction::ZExt: |
| 233 | case Instruction::SExt: |
| 234 | case Instruction::IntToPtr: |
| 235 | case Instruction::PtrToInt: |
| 236 | case Instruction::BitCast: |
| 237 | case Instruction::PHI: |
| 238 | case Instruction::Call: |
| 239 | case Instruction::Select: |
| 240 | case Instruction::Ret: |
| 241 | case Instruction::Load: |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | if (Idx == ImmIdx) { |
| 246 | unsigned NumConstants = (BitSize + 63) / 64; |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 247 | unsigned Cost = AArch64TTIImpl::getIntImmCost(Imm, Ty); |
| 248 | return (Cost <= NumConstants * TTI::TCC_Basic) |
| 249 | ? static_cast<unsigned>(TTI::TCC_Free) |
| 250 | : Cost; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 251 | } |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 252 | return AArch64TTIImpl::getIntImmCost(Imm, Ty); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 253 | } |
| 254 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 255 | unsigned AArch64TTIImpl::getIntImmCost(Intrinsic::ID IID, unsigned Idx, |
| 256 | const APInt &Imm, Type *Ty) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 257 | assert(Ty->isIntegerTy()); |
| 258 | |
| 259 | unsigned BitSize = Ty->getPrimitiveSizeInBits(); |
| 260 | // There is no cost model for constants with a bit size of 0. Return TCC_Free |
| 261 | // here, so that constant hoisting will ignore this constant. |
| 262 | if (BitSize == 0) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 263 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 264 | |
| 265 | switch (IID) { |
| 266 | default: |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 267 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 268 | case Intrinsic::sadd_with_overflow: |
| 269 | case Intrinsic::uadd_with_overflow: |
| 270 | case Intrinsic::ssub_with_overflow: |
| 271 | case Intrinsic::usub_with_overflow: |
| 272 | case Intrinsic::smul_with_overflow: |
| 273 | case Intrinsic::umul_with_overflow: |
| 274 | if (Idx == 1) { |
| 275 | unsigned NumConstants = (BitSize + 63) / 64; |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 276 | unsigned Cost = AArch64TTIImpl::getIntImmCost(Imm, Ty); |
| 277 | return (Cost <= NumConstants * TTI::TCC_Basic) |
| 278 | ? static_cast<unsigned>(TTI::TCC_Free) |
| 279 | : Cost; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 280 | } |
| 281 | break; |
| 282 | case Intrinsic::experimental_stackmap: |
| 283 | if ((Idx < 2) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue()))) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 284 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 285 | break; |
| 286 | case Intrinsic::experimental_patchpoint_void: |
| 287 | case Intrinsic::experimental_patchpoint_i64: |
| 288 | if ((Idx < 4) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue()))) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 289 | return TTI::TCC_Free; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 290 | break; |
| 291 | } |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 292 | return AArch64TTIImpl::getIntImmCost(Imm, Ty); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 295 | TargetTransformInfo::PopcntSupportKind |
| 296 | AArch64TTIImpl::getPopcntSupport(unsigned TyWidth) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 297 | assert(isPowerOf2_32(TyWidth) && "Ty width must be power of 2"); |
| 298 | if (TyWidth == 32 || TyWidth == 64) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 299 | return TTI::PSK_FastHardware; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 300 | // TODO: AArch64TargetLowering::LowerCTPOP() supports 128bit popcount. |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 301 | return TTI::PSK_Software; |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 302 | } |
| 303 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 304 | unsigned AArch64TTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, |
| 305 | Type *Src) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 306 | int ISD = TLI->InstructionOpcodeToISD(Opcode); |
| 307 | assert(ISD && "Invalid opcode"); |
| 308 | |
| 309 | EVT SrcTy = TLI->getValueType(Src); |
| 310 | EVT DstTy = TLI->getValueType(Dst); |
| 311 | |
| 312 | if (!SrcTy.isSimple() || !DstTy.isSimple()) |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 313 | return BaseT::getCastInstrCost(Opcode, Dst, Src); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 314 | |
| 315 | static const TypeConversionCostTblEntry<MVT> ConversionTbl[] = { |
| 316 | // LowerVectorINT_TO_FP: |
| 317 | { ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i32, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 318 | { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i32, 1 }, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 319 | { ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i64, 1 }, |
| 320 | { ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i32, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 321 | { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i32, 1 }, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 322 | { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i64, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 323 | |
| 324 | // Complex: to v2f32 |
| 325 | { ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i8, 3 }, |
| 326 | { ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i16, 3 }, |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 327 | { ISD::SINT_TO_FP, MVT::v2f32, MVT::v2i64, 2 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 328 | { ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i8, 3 }, |
| 329 | { ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i16, 3 }, |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 330 | { ISD::UINT_TO_FP, MVT::v2f32, MVT::v2i64, 2 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 331 | |
| 332 | // Complex: to v4f32 |
| 333 | { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i8, 4 }, |
| 334 | { ISD::SINT_TO_FP, MVT::v4f32, MVT::v4i16, 2 }, |
| 335 | { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i8, 3 }, |
| 336 | { ISD::UINT_TO_FP, MVT::v4f32, MVT::v4i16, 2 }, |
| 337 | |
| 338 | // Complex: to v2f64 |
| 339 | { ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i8, 4 }, |
| 340 | { ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i16, 4 }, |
| 341 | { ISD::SINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 }, |
| 342 | { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i8, 4 }, |
| 343 | { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i16, 4 }, |
| 344 | { ISD::UINT_TO_FP, MVT::v2f64, MVT::v2i32, 2 }, |
| 345 | |
| 346 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 347 | // LowerVectorFP_TO_INT |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 348 | { ISD::FP_TO_SINT, MVT::v2i32, MVT::v2f32, 1 }, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 349 | { ISD::FP_TO_SINT, MVT::v4i32, MVT::v4f32, 1 }, |
| 350 | { ISD::FP_TO_SINT, MVT::v2i64, MVT::v2f64, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 351 | { ISD::FP_TO_UINT, MVT::v2i32, MVT::v2f32, 1 }, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 352 | { ISD::FP_TO_UINT, MVT::v4i32, MVT::v4f32, 1 }, |
| 353 | { ISD::FP_TO_UINT, MVT::v2i64, MVT::v2f64, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 354 | |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 355 | // Complex, from v2f32: legal type is v2i32 (no cost) or v2i64 (1 ext). |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 356 | { ISD::FP_TO_SINT, MVT::v2i64, MVT::v2f32, 2 }, |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 357 | { ISD::FP_TO_SINT, MVT::v2i16, MVT::v2f32, 1 }, |
| 358 | { ISD::FP_TO_SINT, MVT::v2i8, MVT::v2f32, 1 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 359 | { ISD::FP_TO_UINT, MVT::v2i64, MVT::v2f32, 2 }, |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 360 | { ISD::FP_TO_UINT, MVT::v2i16, MVT::v2f32, 1 }, |
| 361 | { ISD::FP_TO_UINT, MVT::v2i8, MVT::v2f32, 1 }, |
| 362 | |
| 363 | // Complex, from v4f32: legal type is v4i16, 1 narrowing => ~2 |
| 364 | { ISD::FP_TO_SINT, MVT::v4i16, MVT::v4f32, 2 }, |
| 365 | { ISD::FP_TO_SINT, MVT::v4i8, MVT::v4f32, 2 }, |
Tim Northover | ef0d760 | 2014-06-15 09:27:06 +0000 | [diff] [blame] | 366 | { ISD::FP_TO_UINT, MVT::v4i16, MVT::v4f32, 2 }, |
Tim Northover | dbecc3b | 2014-06-15 09:27:15 +0000 | [diff] [blame] | 367 | { ISD::FP_TO_UINT, MVT::v4i8, MVT::v4f32, 2 }, |
| 368 | |
| 369 | // Complex, from v2f64: legal type is v2i32, 1 narrowing => ~2. |
| 370 | { ISD::FP_TO_SINT, MVT::v2i32, MVT::v2f64, 2 }, |
| 371 | { ISD::FP_TO_SINT, MVT::v2i16, MVT::v2f64, 2 }, |
| 372 | { ISD::FP_TO_SINT, MVT::v2i8, MVT::v2f64, 2 }, |
| 373 | { ISD::FP_TO_UINT, MVT::v2i32, MVT::v2f64, 2 }, |
| 374 | { ISD::FP_TO_UINT, MVT::v2i16, MVT::v2f64, 2 }, |
| 375 | { ISD::FP_TO_UINT, MVT::v2i8, MVT::v2f64, 2 }, |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 376 | }; |
| 377 | |
| 378 | int Idx = ConvertCostTableLookup<MVT>( |
| 379 | ConversionTbl, array_lengthof(ConversionTbl), ISD, DstTy.getSimpleVT(), |
| 380 | SrcTy.getSimpleVT()); |
| 381 | if (Idx != -1) |
| 382 | return ConversionTbl[Idx].Cost; |
| 383 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 384 | return BaseT::getCastInstrCost(Opcode, Dst, Src); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 385 | } |
| 386 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 387 | unsigned AArch64TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val, |
| 388 | unsigned Index) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 389 | assert(Val->isVectorTy() && "This must be a vector type"); |
| 390 | |
| 391 | if (Index != -1U) { |
| 392 | // Legalize the type. |
| 393 | std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Val); |
| 394 | |
| 395 | // This type is legalized to a scalar type. |
| 396 | if (!LT.second.isVector()) |
| 397 | return 0; |
| 398 | |
| 399 | // The type may be split. Normalize the index to the new type. |
| 400 | unsigned Width = LT.second.getVectorNumElements(); |
| 401 | Index = Index % Width; |
| 402 | |
| 403 | // The element at index zero is already inside the vector. |
| 404 | if (Index == 0) |
| 405 | return 0; |
| 406 | } |
| 407 | |
| 408 | // All other insert/extracts cost this much. |
| 409 | return 2; |
| 410 | } |
| 411 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 412 | unsigned AArch64TTIImpl::getArithmeticInstrCost( |
| 413 | unsigned Opcode, Type *Ty, TTI::OperandValueKind Opd1Info, |
| 414 | TTI::OperandValueKind Opd2Info, TTI::OperandValueProperties Opd1PropInfo, |
| 415 | TTI::OperandValueProperties Opd2PropInfo) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 416 | // Legalize the type. |
| 417 | std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Ty); |
| 418 | |
| 419 | int ISD = TLI->InstructionOpcodeToISD(Opcode); |
| 420 | |
Chad Rosier | 70d54ac | 2014-09-29 13:59:31 +0000 | [diff] [blame] | 421 | if (ISD == ISD::SDIV && |
| 422 | Opd2Info == TargetTransformInfo::OK_UniformConstantValue && |
| 423 | Opd2PropInfo == TargetTransformInfo::OP_PowerOf2) { |
| 424 | // On AArch64, scalar signed division by constants power-of-two are |
| 425 | // normally expanded to the sequence ADD + CMP + SELECT + SRA. |
| 426 | // The OperandValue properties many not be same as that of previous |
| 427 | // operation; conservatively assume OP_None. |
| 428 | unsigned Cost = |
| 429 | getArithmeticInstrCost(Instruction::Add, Ty, Opd1Info, Opd2Info, |
| 430 | TargetTransformInfo::OP_None, |
| 431 | TargetTransformInfo::OP_None); |
| 432 | Cost += getArithmeticInstrCost(Instruction::Sub, Ty, Opd1Info, Opd2Info, |
| 433 | TargetTransformInfo::OP_None, |
| 434 | TargetTransformInfo::OP_None); |
| 435 | Cost += getArithmeticInstrCost(Instruction::Select, Ty, Opd1Info, Opd2Info, |
| 436 | TargetTransformInfo::OP_None, |
| 437 | TargetTransformInfo::OP_None); |
| 438 | Cost += getArithmeticInstrCost(Instruction::AShr, Ty, Opd1Info, Opd2Info, |
| 439 | TargetTransformInfo::OP_None, |
| 440 | TargetTransformInfo::OP_None); |
| 441 | return Cost; |
| 442 | } |
| 443 | |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 444 | switch (ISD) { |
| 445 | default: |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 446 | return BaseT::getArithmeticInstrCost(Opcode, Ty, Opd1Info, Opd2Info, |
| 447 | Opd1PropInfo, Opd2PropInfo); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 448 | case ISD::ADD: |
| 449 | case ISD::MUL: |
| 450 | case ISD::XOR: |
| 451 | case ISD::OR: |
| 452 | case ISD::AND: |
| 453 | // These nodes are marked as 'custom' for combining purposes only. |
| 454 | // We know that they are legal. See LowerAdd in ISelLowering. |
| 455 | return 1 * LT.first; |
| 456 | } |
| 457 | } |
| 458 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 459 | unsigned AArch64TTIImpl::getAddressComputationCost(Type *Ty, bool IsComplex) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 460 | // Address computations in vectorized code with non-consecutive addresses will |
| 461 | // likely result in more instructions compared to scalar code where the |
| 462 | // computation can more often be merged into the index mode. The resulting |
| 463 | // extra micro-ops can significantly decrease throughput. |
| 464 | unsigned NumVectorInstToHideOverhead = 10; |
| 465 | |
| 466 | if (Ty->isVectorTy() && IsComplex) |
| 467 | return NumVectorInstToHideOverhead; |
| 468 | |
| 469 | // In many cases the address computation is not merged into the instruction |
| 470 | // addressing mode. |
| 471 | return 1; |
| 472 | } |
| 473 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 474 | unsigned AArch64TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, |
| 475 | Type *CondTy) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 476 | |
| 477 | int ISD = TLI->InstructionOpcodeToISD(Opcode); |
| 478 | // We don't lower vector selects well that are wider than the register width. |
| 479 | if (ValTy->isVectorTy() && ISD == ISD::SELECT) { |
| 480 | // We would need this many instructions to hide the scalarization happening. |
| 481 | unsigned AmortizationCost = 20; |
| 482 | static const TypeConversionCostTblEntry<MVT::SimpleValueType> |
| 483 | VectorSelectTbl[] = { |
| 484 | { ISD::SELECT, MVT::v16i1, MVT::v16i16, 16 * AmortizationCost }, |
| 485 | { ISD::SELECT, MVT::v8i1, MVT::v8i32, 8 * AmortizationCost }, |
| 486 | { ISD::SELECT, MVT::v16i1, MVT::v16i32, 16 * AmortizationCost }, |
| 487 | { ISD::SELECT, MVT::v4i1, MVT::v4i64, 4 * AmortizationCost }, |
| 488 | { ISD::SELECT, MVT::v8i1, MVT::v8i64, 8 * AmortizationCost }, |
| 489 | { ISD::SELECT, MVT::v16i1, MVT::v16i64, 16 * AmortizationCost } |
| 490 | }; |
| 491 | |
| 492 | EVT SelCondTy = TLI->getValueType(CondTy); |
| 493 | EVT SelValTy = TLI->getValueType(ValTy); |
| 494 | if (SelCondTy.isSimple() && SelValTy.isSimple()) { |
| 495 | int Idx = |
| 496 | ConvertCostTableLookup(VectorSelectTbl, ISD, SelCondTy.getSimpleVT(), |
| 497 | SelValTy.getSimpleVT()); |
| 498 | if (Idx != -1) |
| 499 | return VectorSelectTbl[Idx].Cost; |
| 500 | } |
| 501 | } |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 502 | return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy); |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 503 | } |
| 504 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 505 | unsigned AArch64TTIImpl::getMemoryOpCost(unsigned Opcode, Type *Src, |
| 506 | unsigned Alignment, |
| 507 | unsigned AddressSpace) { |
Tim Northover | 3b0846e | 2014-05-24 12:50:23 +0000 | [diff] [blame] | 508 | std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(Src); |
| 509 | |
| 510 | if (Opcode == Instruction::Store && Src->isVectorTy() && Alignment != 16 && |
| 511 | Src->getVectorElementType()->isIntegerTy(64)) { |
| 512 | // Unaligned stores are extremely inefficient. We don't split |
| 513 | // unaligned v2i64 stores because the negative impact that has shown in |
| 514 | // practice on inlined memcpy code. |
| 515 | // We make v2i64 stores expensive so that we will only vectorize if there |
| 516 | // are 6 other instructions getting vectorized. |
| 517 | unsigned AmortizationCost = 6; |
| 518 | |
| 519 | return LT.first * 2 * AmortizationCost; |
| 520 | } |
| 521 | |
| 522 | if (Src->isVectorTy() && Src->getVectorElementType()->isIntegerTy(8) && |
| 523 | Src->getVectorNumElements() < 8) { |
| 524 | // We scalarize the loads/stores because there is not v.4b register and we |
| 525 | // have to promote the elements to v.4h. |
| 526 | unsigned NumVecElts = Src->getVectorNumElements(); |
| 527 | unsigned NumVectorizableInstsToAmortize = NumVecElts * 2; |
| 528 | // We generate 2 instructions per vector element. |
| 529 | return NumVectorizableInstsToAmortize * NumVecElts * 2; |
| 530 | } |
| 531 | |
| 532 | return LT.first; |
| 533 | } |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame] | 534 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 535 | unsigned AArch64TTIImpl::getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) { |
James Molloy | 2b8933c | 2014-08-05 12:30:34 +0000 | [diff] [blame] | 536 | unsigned Cost = 0; |
| 537 | for (auto *I : Tys) { |
| 538 | if (!I->isVectorTy()) |
| 539 | continue; |
| 540 | if (I->getScalarSizeInBits() * I->getVectorNumElements() == 128) |
| 541 | Cost += getMemoryOpCost(Instruction::Store, I, 128, 0) + |
| 542 | getMemoryOpCost(Instruction::Load, I, 128, 0); |
| 543 | } |
| 544 | return Cost; |
| 545 | } |
James Molloy | a88896b | 2014-08-21 00:02:51 +0000 | [diff] [blame] | 546 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 547 | unsigned AArch64TTIImpl::getMaxInterleaveFactor() { |
Gerolf Hoflehner | 7b0abb8 | 2014-09-10 20:31:57 +0000 | [diff] [blame] | 548 | if (ST->isCortexA57()) |
James Molloy | a88896b | 2014-08-21 00:02:51 +0000 | [diff] [blame] | 549 | return 4; |
| 550 | return 2; |
| 551 | } |
Kevin Qin | 72a799a | 2014-10-09 10:13:27 +0000 | [diff] [blame] | 552 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 553 | void AArch64TTIImpl::getUnrollingPreferences(const Function *F, Loop *L, |
| 554 | TTI::UnrollingPreferences &UP) { |
Kevin Qin | 72a799a | 2014-10-09 10:13:27 +0000 | [diff] [blame] | 555 | // Disable partial & runtime unrolling on -Os. |
| 556 | UP.PartialOptSizeThreshold = 0; |
| 557 | } |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 558 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 559 | Value *AArch64TTIImpl::getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst, |
| 560 | Type *ExpectedType) { |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 561 | switch (Inst->getIntrinsicID()) { |
| 562 | default: |
| 563 | return nullptr; |
| 564 | case Intrinsic::aarch64_neon_st2: |
| 565 | case Intrinsic::aarch64_neon_st3: |
| 566 | case Intrinsic::aarch64_neon_st4: { |
| 567 | // Create a struct type |
| 568 | StructType *ST = dyn_cast<StructType>(ExpectedType); |
| 569 | if (!ST) |
| 570 | return nullptr; |
| 571 | unsigned NumElts = Inst->getNumArgOperands() - 1; |
| 572 | if (ST->getNumElements() != NumElts) |
| 573 | return nullptr; |
| 574 | for (unsigned i = 0, e = NumElts; i != e; ++i) { |
| 575 | if (Inst->getArgOperand(i)->getType() != ST->getElementType(i)) |
| 576 | return nullptr; |
| 577 | } |
| 578 | Value *Res = UndefValue::get(ExpectedType); |
| 579 | IRBuilder<> Builder(Inst); |
| 580 | for (unsigned i = 0, e = NumElts; i != e; ++i) { |
| 581 | Value *L = Inst->getArgOperand(i); |
| 582 | Res = Builder.CreateInsertValue(Res, L, i); |
| 583 | } |
| 584 | return Res; |
| 585 | } |
| 586 | case Intrinsic::aarch64_neon_ld2: |
| 587 | case Intrinsic::aarch64_neon_ld3: |
| 588 | case Intrinsic::aarch64_neon_ld4: |
| 589 | if (Inst->getType() == ExpectedType) |
| 590 | return Inst; |
| 591 | return nullptr; |
| 592 | } |
| 593 | } |
| 594 | |
Chandler Carruth | 705b185 | 2015-01-31 03:43:40 +0000 | [diff] [blame^] | 595 | bool AArch64TTIImpl::getTgtMemIntrinsic(IntrinsicInst *Inst, |
| 596 | MemIntrinsicInfo &Info) { |
Chad Rosier | f9327d6 | 2015-01-26 22:51:15 +0000 | [diff] [blame] | 597 | switch (Inst->getIntrinsicID()) { |
| 598 | default: |
| 599 | break; |
| 600 | case Intrinsic::aarch64_neon_ld2: |
| 601 | case Intrinsic::aarch64_neon_ld3: |
| 602 | case Intrinsic::aarch64_neon_ld4: |
| 603 | Info.ReadMem = true; |
| 604 | Info.WriteMem = false; |
| 605 | Info.Vol = false; |
| 606 | Info.NumMemRefs = 1; |
| 607 | Info.PtrVal = Inst->getArgOperand(0); |
| 608 | break; |
| 609 | case Intrinsic::aarch64_neon_st2: |
| 610 | case Intrinsic::aarch64_neon_st3: |
| 611 | case Intrinsic::aarch64_neon_st4: |
| 612 | Info.ReadMem = false; |
| 613 | Info.WriteMem = true; |
| 614 | Info.Vol = false; |
| 615 | Info.NumMemRefs = 1; |
| 616 | Info.PtrVal = Inst->getArgOperand(Inst->getNumArgOperands() - 1); |
| 617 | break; |
| 618 | } |
| 619 | |
| 620 | switch (Inst->getIntrinsicID()) { |
| 621 | default: |
| 622 | return false; |
| 623 | case Intrinsic::aarch64_neon_ld2: |
| 624 | case Intrinsic::aarch64_neon_st2: |
| 625 | Info.MatchingId = VECTOR_LDST_TWO_ELEMENTS; |
| 626 | break; |
| 627 | case Intrinsic::aarch64_neon_ld3: |
| 628 | case Intrinsic::aarch64_neon_st3: |
| 629 | Info.MatchingId = VECTOR_LDST_THREE_ELEMENTS; |
| 630 | break; |
| 631 | case Intrinsic::aarch64_neon_ld4: |
| 632 | case Intrinsic::aarch64_neon_st4: |
| 633 | Info.MatchingId = VECTOR_LDST_FOUR_ELEMENTS; |
| 634 | break; |
| 635 | } |
| 636 | return true; |
| 637 | } |