llvm.org GIT mirror llvm / 34ae7b5
[ConstantFolding] Reduce APInt and APFloat copying. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@260826 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
2 changed file(s) with 8 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
16771677 }
16781678 if (IntrinsicID == Intrinsic::copysign) {
16791679 APFloat V1 = Op1->getValueAPF();
1680 APFloat V2 = Op2->getValueAPF();
1680 const APFloat &V2 = Op2->getValueAPF();
16811681 V1.copySign(V2);
16821682 return ConstantFP::get(Ty->getContext(), V1);
16831683 }
668668 case Instruction::UIToFP:
669669 case Instruction::SIToFP:
670670 if (ConstantInt *CI = dyn_cast(V)) {
671 APInt api = CI->getValue();
671 const APInt &api = CI->getValue();
672672 APFloat apf(DestTy->getFltSemantics(),
673673 APInt::getNullValue(DestTy->getPrimitiveSizeInBits()));
674674 if (APFloat::opOverflow &
11671167 }
11681168 } else if (ConstantFP *CFP1 = dyn_cast(C1)) {
11691169 if (ConstantFP *CFP2 = dyn_cast(C2)) {
1170 APFloat C1V = CFP1->getValueAPF();
1171 APFloat C2V = CFP2->getValueAPF();
1170 const APFloat &C1V = CFP1->getValueAPF();
1171 const APFloat &C2V = CFP2->getValueAPF();
11721172 APFloat C3V = C1V; // copy for modification
11731173 switch (Opcode) {
11741174 default:
17281728 }
17291729
17301730 if (isa(C1) && isa(C2)) {
1731 APInt V1 = cast(C1)->getValue();
1732 APInt V2 = cast(C2)->getValue();
1731 const APInt &V1 = cast(C1)->getValue();
1732 const APInt &V2 = cast(C2)->getValue();
17331733 switch (pred) {
17341734 default: llvm_unreachable("Invalid ICmp Predicate");
17351735 case ICmpInst::ICMP_EQ: return ConstantInt::get(ResultTy, V1 == V2);
17441744 case ICmpInst::ICMP_UGE: return ConstantInt::get(ResultTy, V1.uge(V2));
17451745 }
17461746 } else if (isa(C1) && isa(C2)) {
1747 APFloat C1V = cast(C1)->getValueAPF();
1748 APFloat C2V = cast(C2)->getValueAPF();
1747 const APFloat &C1V = cast(C1)->getValueAPF();
1748 const APFloat &C2V = cast(C2)->getValueAPF();
17491749 APFloat::cmpResult R = C1V.compare(C2V);
17501750 switch (pred) {
17511751 default: llvm_unreachable("Invalid FCmp Predicate");