R600/SI: Using SGPRs is illegal for instructions that read carry-out from VCC
[oota-llvm.git] / lib / Analysis / ConstantFolding.cpp
index 08b60671a63898c773b5d15f468c836805e312d0..8ff79d6f6255702a2fa975047464c4e9ae7cb584 100644 (file)
@@ -1195,6 +1195,8 @@ bool llvm::canConstantFoldCallTo(const Function *F) {
   case Intrinsic::cttz:
   case Intrinsic::fma:
   case Intrinsic::fmuladd:
+  case Intrinsic::copysign:
+  case Intrinsic::round:
   case Intrinsic::sadd_with_overflow:
   case Intrinsic::uadd_with_overflow:
   case Intrinsic::ssub_with_overflow:
@@ -1344,6 +1346,12 @@ static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
       if (!Ty->isHalfTy() && !Ty->isFloatTy() && !Ty->isDoubleTy())
         return 0;
 
+      if (IntrinsicID == Intrinsic::round) {
+        APFloat V = Op->getValueAPF();
+        V.roundToIntegral(APFloat::rmNearestTiesToAway);
+        return ConstantFP::get(Ty->getContext(), V);
+      }
+
       /// We only fold functions with finite arguments. Folding NaN and inf is
       /// likely to be aborted with an exception anyway, and some host libms
       /// have known errors raising exceptions.
@@ -1532,6 +1540,12 @@ static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
         if (IntrinsicID == Intrinsic::pow) {
           return ConstantFoldBinaryFP(pow, Op1V, Op2V, Ty);
         }
+        if (IntrinsicID == Intrinsic::copysign) {
+          APFloat V1 = Op1->getValueAPF();
+          APFloat V2 = Op2->getValueAPF();
+          V1.copySign(V2);
+          return ConstantFP::get(Ty->getContext(), V1);
+        }
         if (!TLI)
           return 0;
         if (Name == "pow" && TLI->has(LibFunc::pow))