comparison lib/Target/Hexagon/HexagonTargetTransformInfo.cpp @ 120:1172e4bd9c6f

update 4.0.0
author mir3636
date Fri, 25 Nov 2016 19:14:25 +0900
parents afa8332a0e37
children 803732b1fca8
comparison
equal deleted inserted replaced
101:34baf5011add 120:1172e4bd9c6f
12 /// independent and default TTI implementations handle the rest. 12 /// independent and default TTI implementations handle the rest.
13 /// 13 ///
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "HexagonTargetTransformInfo.h" 16 #include "HexagonTargetTransformInfo.h"
17 #include "llvm/IR/Instructions.h"
17 #include "llvm/Support/Debug.h" 18 #include "llvm/Support/Debug.h"
18 19
19 using namespace llvm; 20 using namespace llvm;
20 21
21 #define DEBUG_TYPE "hexagontti" 22 #define DEBUG_TYPE "hexagontti"
34 } 35 }
35 36
36 unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const { 37 unsigned HexagonTTIImpl::getNumberOfRegisters(bool vector) const {
37 return vector ? 0 : 32; 38 return vector ? 0 : 32;
38 } 39 }
40
41 unsigned HexagonTTIImpl::getPrefetchDistance() const {
42 return getST()->getL1PrefetchDistance();
43 }
44
45 unsigned HexagonTTIImpl::getCacheLineSize() const {
46 return getST()->getL1CacheLineSize();
47 }
48
49 int HexagonTTIImpl::getUserCost(const User *U) {
50 auto isCastFoldedIntoLoad = [] (const CastInst *CI) -> bool {
51 if (!CI->isIntegerCast())
52 return false;
53 const LoadInst *LI = dyn_cast<const LoadInst>(CI->getOperand(0));
54 // Technically, this code could allow multiple uses of the load, and
55 // check if all the uses are the same extension operation, but this
56 // should be sufficient for most cases.
57 if (!LI || !LI->hasOneUse())
58 return false;
59
60 // Only extensions from an integer type shorter than 32-bit to i32
61 // can be folded into the load.
62 unsigned SBW = CI->getSrcTy()->getIntegerBitWidth();
63 unsigned DBW = CI->getDestTy()->getIntegerBitWidth();
64 return DBW == 32 && (SBW < DBW);
65 };
66
67 if (const CastInst *CI = dyn_cast<const CastInst>(U))
68 if (isCastFoldedIntoLoad(CI))
69 return TargetTransformInfo::TCC_Free;
70 return BaseT::getUserCost(U);
71 }