[PATCH] D103169: [FPEnv][InstSimplify] Constrained FP support for NaN

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 14 10:21:12 PDT 2021


sepavloff added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4900
+                 RoundingMode Rounding = RoundingMode::NearestTiesToEven) {
+  if (IsDefaultFPEnvironment(ExBehavior, Rounding))
+    if (Constant *C = foldOrCommuteConstant(Instruction::FSub, Op0, Op1, Q))
----------------
Is default environment is necessary to make constant folding? "fpexcept.maytrap" also allows constant evaluation and any rounding except dynamic does not prevent the evaluation. Maybe check only for `ExBehavior != fp::ebStrict`?


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4951
+                              RoundingMode Rounding) {
+  if (Constant *C = simplifyFPOp({Op0, Op1}, FMF, Q, ExBehavior, Rounding))
     return C;
----------------
In contrast to other `Simplify*` functions there is no call to `foldOrCommuteConstant`. May it be put here?


================
Comment at: llvm/test/Transforms/InstSimplify/X86/fp-nan-strictfp.ll:305
+
+define float @frem_nan_op0_upward(float %x) {
+; CHECK-LABEL: @frem_nan_op0_upward(
----------------
Calculation of remainder does not depend on rounding mode, so this test is identical to the next.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103169/new/

https://reviews.llvm.org/D103169



More information about the llvm-commits mailing list