[llvm] r260826 - [ConstantFolding] Reduce APInt and APFloat copying.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 13 08:54:14 PST 2016
Author: d0k
Date: Sat Feb 13 10:54:14 2016
New Revision: 260826
URL: http://llvm.org/viewvc/llvm-project?rev=260826&view=rev
Log:
[ConstantFolding] Reduce APInt and APFloat copying.
Modified:
llvm/trunk/lib/Analysis/ConstantFolding.cpp
llvm/trunk/lib/IR/ConstantFold.cpp
Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=260826&r1=260825&r2=260826&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Sat Feb 13 10:54:14 2016
@@ -1678,7 +1678,7 @@ static Constant *ConstantFoldScalarCall(
}
if (IntrinsicID == Intrinsic::copysign) {
APFloat V1 = Op1->getValueAPF();
- APFloat V2 = Op2->getValueAPF();
+ const APFloat &V2 = Op2->getValueAPF();
V1.copySign(V2);
return ConstantFP::get(Ty->getContext(), V1);
}
Modified: llvm/trunk/lib/IR/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantFold.cpp?rev=260826&r1=260825&r2=260826&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantFold.cpp (original)
+++ llvm/trunk/lib/IR/ConstantFold.cpp Sat Feb 13 10:54:14 2016
@@ -669,7 +669,7 @@ Constant *llvm::ConstantFoldCastInstruct
case Instruction::UIToFP:
case Instruction::SIToFP:
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
- APInt api = CI->getValue();
+ const APInt &api = CI->getValue();
APFloat apf(DestTy->getFltSemantics(),
APInt::getNullValue(DestTy->getPrimitiveSizeInBits()));
if (APFloat::opOverflow &
@@ -1168,8 +1168,8 @@ Constant *llvm::ConstantFoldBinaryInstru
}
} else if (ConstantFP *CFP1 = dyn_cast<ConstantFP>(C1)) {
if (ConstantFP *CFP2 = dyn_cast<ConstantFP>(C2)) {
- APFloat C1V = CFP1->getValueAPF();
- APFloat C2V = CFP2->getValueAPF();
+ const APFloat &C1V = CFP1->getValueAPF();
+ const APFloat &C2V = CFP2->getValueAPF();
APFloat C3V = C1V; // copy for modification
switch (Opcode) {
default:
@@ -1729,8 +1729,8 @@ Constant *llvm::ConstantFoldCompareInstr
}
if (isa<ConstantInt>(C1) && isa<ConstantInt>(C2)) {
- APInt V1 = cast<ConstantInt>(C1)->getValue();
- APInt V2 = cast<ConstantInt>(C2)->getValue();
+ const APInt &V1 = cast<ConstantInt>(C1)->getValue();
+ const APInt &V2 = cast<ConstantInt>(C2)->getValue();
switch (pred) {
default: llvm_unreachable("Invalid ICmp Predicate");
case ICmpInst::ICMP_EQ: return ConstantInt::get(ResultTy, V1 == V2);
@@ -1745,8 +1745,8 @@ Constant *llvm::ConstantFoldCompareInstr
case ICmpInst::ICMP_UGE: return ConstantInt::get(ResultTy, V1.uge(V2));
}
} else if (isa<ConstantFP>(C1) && isa<ConstantFP>(C2)) {
- APFloat C1V = cast<ConstantFP>(C1)->getValueAPF();
- APFloat C2V = cast<ConstantFP>(C2)->getValueAPF();
+ const APFloat &C1V = cast<ConstantFP>(C1)->getValueAPF();
+ const APFloat &C2V = cast<ConstantFP>(C2)->getValueAPF();
APFloat::cmpResult R = C1V.compare(C2V);
switch (pred) {
default: llvm_unreachable("Invalid FCmp Predicate");
More information about the llvm-commits
mailing list