diff options
author | Alex Bradbury <asb@igalia.com> | 2024-04-25 15:05:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 15:05:07 +0100 |
commit | 1c8410a67d9d7bbadc2e5f2c8698531b1060c8ac (patch) | |
tree | 4adf27ca74c09ca5d54123c9c0baf262a01de1e0 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 2554a85c0375b4c1c7c4f461811babef67e1a403 (diff) | |
download | llvm-1c8410a67d9d7bbadc2e5f2c8698531b1060c8ac.zip llvm-1c8410a67d9d7bbadc2e5f2c8698531b1060c8ac.tar.gz llvm-1c8410a67d9d7bbadc2e5f2c8698531b1060c8ac.tar.bz2 |
[CodeGenPrepare] Preserve flags (such as nsw/nuw) in SinkCast (#89904)
As demonstrated in the test change, when deciding to sink a trunc we
were losing its flags. This patch moves to cloning the original
instruction instead.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 22a766f..8eaf781 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -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 = cast<CastInst>(CI->clone()); InsertedCast->insertBefore(*UserBB, InsertPt); - InsertedCast->setDebugLoc(CI->getDebugLoc()); } // Replace a use of the cast with a use of the new cast. |