[PATCH] D136442: [GISel] Add (fsub +-0.0, X) -> fneg combine
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 21 08:02:34 PDT 2022
arsenm added inline comments.
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:5251
+ const auto LHSCst = getFConstantVRegValWithLookThrough(LHS, MRI);
+ return LHSCst && LHSCst->Value.isZero();
+}
----------------
Doing this for -0 is only valid with nsz: [[ https://alive2.llvm.org/ce/z/SK2Bs9 ]]
================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:5256
+ Builder.setInstrAndDebugLoc(MI);
+ Builder.buildFNeg(MI.getOperand(0).getReg(), MatchInfo);
+ eraseInst(MI);
----------------
This changes a canonicalizing operation to a non-canonicalizing operation. You need to introduce a canonicalize unless you know denormals aren't flushed and the source isn't a signaling nan. InstCombine currently has a bug where it ignores this.
The DAG also has getNegatedExpression, which may be overkill at this moment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136442/new/
https://reviews.llvm.org/D136442
More information about the llvm-commits
mailing list