[llvm] [CodeGenPrepare] Preserve flags (such as nsw/nuw) in SinkCast (PR #89904)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 04:14:48 PDT 2024


================
@@ -1431,10 +1431,8 @@ static bool SinkCast(CastInst *CI) {
     if (!InsertedCast) {
       BasicBlock::iterator InsertPt = UserBB->getFirstInsertionPt();
       assert(InsertPt != UserBB->end());
-      InsertedCast = CastInst::Create(CI->getOpcode(), CI->getOperand(0),
-                                      CI->getType(), "");
+      InsertedCast = static_cast<CastInst *>(CI->clone());
----------------
nikic wrote:

```suggestion
      InsertedCast = cast<CastInst>(CI->clone());
```

https://github.com/llvm/llvm-project/pull/89904


More information about the llvm-commits mailing list