Skip to content

Commit 5580ecd

Browse files
committed
[InstCombine] Create new insts
1 parent c532d57 commit 5580ecd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,8 +2674,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
26742674
// copysign Mag, (copysign ?, X) --> copysign Mag, X
26752675
Value *X;
26762676
if (match(Sign, m_Intrinsic<Intrinsic::copysign>(m_Value(), m_Value(X)))) {
2677-
II->andIRFlags(Sign);
2678-
return replaceOperand(*II, 1, X);
2677+
IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
2678+
Builder.setFastMathFlags(II->getFastMathFlags() &
2679+
cast<Instruction>(Sign)->getFastMathFlags());
2680+
Value *CopySign =
2681+
Builder.CreateBinaryIntrinsic(Intrinsic::copysign, Mag, X);
2682+
return replaceInstUsesWith(*II, CopySign);
26792683
}
26802684

26812685
// Clear sign-bit of constant magnitude:

0 commit comments

Comments
 (0)