[llvm] 3a12f35 - [IR] Mark FP casts constant exprs as undesirable

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 07:04:41 PST 2023


Author: Nikita Popov
Date: 2023-11-06T16:04:32+01:00
New Revision: 3a12f355ab418baff9fd48a541ab86128960d3cb

URL: https://github.com/llvm/llvm-project/commit/3a12f355ab418baff9fd48a541ab86128960d3cb
DIFF: https://github.com/llvm/llvm-project/commit/3a12f355ab418baff9fd48a541ab86128960d3cb.diff

LOG: [IR] Mark FP casts constant exprs as undesirable

We will no longer generate these constant expressions by default,
but they can still be explicitly created.

Added: 
    

Modified: 
    llvm/lib/IR/Constants.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index cca481181068d7e..16072d2efc95bfd 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -2270,14 +2270,14 @@ bool ConstantExpr::isDesirableCastOp(unsigned Opcode) {
   switch (Opcode) {
   case Instruction::ZExt:
   case Instruction::SExt:
-    return false;
-  case Instruction::Trunc:
   case Instruction::FPTrunc:
   case Instruction::FPExt:
   case Instruction::UIToFP:
   case Instruction::SIToFP:
   case Instruction::FPToUI:
   case Instruction::FPToSI:
+    return false;
+  case Instruction::Trunc:
   case Instruction::PtrToInt:
   case Instruction::IntToPtr:
   case Instruction::BitCast:


        


More information about the llvm-commits mailing list