[llvm] [InstCombine] Fix FMF propagation in `copysign Mag, (copysign ?, X) -> copysign Mag, X` (PR #121574)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 4 03:37:06 PST 2025
================
@@ -2645,8 +2645,12 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
// copysign Mag, (copysign ?, X) --> copysign Mag, X
Value *X;
if (match(Sign, m_Intrinsic<Intrinsic::copysign>(m_Value(), m_Value(X)))) {
- II->andIRFlags(Sign);
- return replaceOperand(*II, 1, X);
+ IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
+ Builder.setFastMathFlags(II->getFastMathFlags() &
+ cast<Instruction>(Sign)->getFastMathFlags());
+ Value *CopySign =
+ Builder.CreateBinaryIntrinsic(Intrinsic::copysign, Mag, X);
----------------
arsenm wrote:
We really ought to add FMF arguments to all these CreateFunctions, the guard + set is so clumsy
https://github.com/llvm/llvm-project/pull/121574
More information about the llvm-commits
mailing list