diff options
author | Dan Gohman <gohman@apple.com> | 2008-10-07 22:03:27 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-10-07 22:03:27 +0000 |
commit | 1e9e8c3bd5ac018296bddb21a2acb8c643303b39 (patch) | |
tree | a2271ea5e8ddcda236d10a1f62d68f69aca0ed9c /lib/CodeGen/SelectionDAG/FastISel.cpp | |
parent | 145b828014397f02ec0e35f3ba768b61a36b0b9f (diff) |
Avoid emitting redundant materializations of integer constants
for things like null pointers, which at this level aren't
different from regular integer constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 17b37a3445..f9cfeb1e97 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -81,7 +81,9 @@ unsigned FastISel::getRegForValue(Value *V) { } else if (isa<AllocaInst>(V)) { Reg = TargetMaterializeAlloca(cast<AllocaInst>(V)); } else if (isa<ConstantPointerNull>(V)) { - Reg = FastEmit_i(VT, VT, ISD::Constant, 0); + // Translate this as an integer zero so that it can be + // local-CSE'd with actual integer zeros. + Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType())); } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) { Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); @@ -95,8 +97,7 @@ unsigned FastISel::getRegForValue(Value *V) { APFloat::rmTowardZero) != APFloat::opOK) { APInt IntVal(IntBitWidth, 2, x); - unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(), - ISD::Constant, IntVal.getZExtValue()); + unsigned IntegerReg = getRegForValue(ConstantInt::get(IntVal)); if (IntegerReg != 0) Reg = FastEmit_r(IntVT.getSimpleVT(), VT, ISD::SINT_TO_FP, IntegerReg); } |