[llvm] 16a595e - [Attributor] Avoid use of ConstantExpr::getFPTrunc() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 06:29:32 PST 2023


Author: Nikita Popov
Date: 2023-11-06T15:27:01+01:00
New Revision: 16a595e398f3e4f1b7374208fc32c4059b4df84a

URL: https://github.com/llvm/llvm-project/commit/16a595e398f3e4f1b7374208fc32c4059b4df84a
DIFF: https://github.com/llvm/llvm-project/commit/16a595e398f3e4f1b7374208fc32c4059b4df84a.diff

LOG: [Attributor] Avoid use of ConstantExpr::getFPTrunc() (NFC)

Use the constant folding API instead. For simplificity I'm using
the DL-independent API here.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Attributor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 49ced893d5c7340..50e4a8b87a5d2dd 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -330,7 +330,7 @@ Value *AA::getWithType(Value &V, Type &Ty) {
       if (C->getType()->isIntegerTy() && Ty.isIntegerTy())
         return ConstantExpr::getTrunc(C, &Ty, /* OnlyIfReduced */ true);
       if (C->getType()->isFloatingPointTy() && Ty.isFloatingPointTy())
-        return ConstantExpr::getFPTrunc(C, &Ty, /* OnlyIfReduced */ true);
+        return ConstantFoldCastInstruction(Instruction::FPTrunc, C, &Ty);
     }
   }
   return nullptr;


        


More information about the llvm-commits mailing list