aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/SelectionDAG/FastISel.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-09-19 22:16:54 +0000
committerDan Gohman <gohman@apple.com>2008-09-19 22:16:54 +0000
commit2ff7fd146159d97abe94391a33b4385abb06bbb0 (patch)
treee89dff6ddeb34edb1bca64719c9d55763ab4ba92 /lib/CodeGen/SelectionDAG/FastISel.cpp
parentd6bd73353403fd6f132d20b68750fe4bf8c0af64 (diff)
Refactor X86SelectConstAddr, folding it into X86SelectAddress. This
results in better code for globals. Also, unbreak the local CSE for GlobalValue stub loads. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r--lib/CodeGen/SelectionDAG/FastISel.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp
index 13b1793e05..3139cb3bc7 100644
--- a/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -44,15 +44,10 @@ unsigned FastISel::getRegForValue(Value *V) {
}
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
- if (CI->getValue().getActiveBits() > 64)
- return TargetMaterializeConstant(CI);
- // Don't cache constant materializations. To do so would require
- // tracking what uses they dominate.
- Reg = FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
- } else if (isa<GlobalValue>(V)) {
- return TargetMaterializeConstant(cast<Constant>(V));
+ if (CI->getValue().getActiveBits() <= 64)
+ Reg = FastEmit_i(VT, VT, ISD::Constant, CI->getZExtValue());
} else if (isa<AllocaInst>(V)) {
- return TargetMaterializeAlloca(cast<AllocaInst>(V));
+ Reg = TargetMaterializeAlloca(cast<AllocaInst>(V));
} else if (isa<ConstantPointerNull>(V)) {
Reg = FastEmit_i(VT, VT, ISD::Constant, 0);
} else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
@@ -64,18 +59,15 @@ unsigned FastISel::getRegForValue(Value *V) {
uint64_t x[2];
uint32_t IntBitWidth = IntVT.getSizeInBits();
- if (Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true,
- APFloat::rmTowardZero) != APFloat::opOK)
- return TargetMaterializeConstant(CF);
- APInt IntVal(IntBitWidth, 2, x);
-
- unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(),
- ISD::Constant, IntVal.getZExtValue());
- if (IntegerReg == 0)
- return TargetMaterializeConstant(CF);
- Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
- if (Reg == 0)
- return TargetMaterializeConstant(CF);
+ if (!Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true,
+ APFloat::rmTowardZero) != APFloat::opOK) {
+ APInt IntVal(IntBitWidth, 2, x);
+
+ unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(),
+ ISD::Constant, IntVal.getZExtValue());
+ if (IntegerReg != 0)
+ Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg);
+ }
}
} else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(V)) {
if (!SelectOperator(CE, CE->getOpcode())) return 0;
@@ -88,8 +80,10 @@ unsigned FastISel::getRegForValue(Value *V) {
}
if (!Reg && isa<Constant>(V))
- return TargetMaterializeConstant(cast<Constant>(V));
+ Reg = TargetMaterializeConstant(cast<Constant>(V));
+ // Don't cache constant materializations in the general ValueMap.
+ // To do so would require tracking what uses they dominate.
LocalValueMap[V] = Reg;
return Reg;
}