[PATCH] D59947: [NVPTX] Fix the codegen for llvm.round.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 13:42:20 PDT 2019


tra added inline comments.


================
Comment at: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:2107
+  SDValue Sign = DAG.getNode(ISD::AND, SL, MVT::i32, Bitcast,
+                             DAG.getConstant(-2147483648, SL, MVT::i32));
+  SDValue PointFiveRaw = DAG.getNode(ISD::OR, SL, MVT::i32, Sign,
----------------
Do we have FP32-related constants defined somewhere in LLVM tree?
It would be easier to understand if we could use `1 << SIGN_BIT_SHIFT` here or `((0 + EXP_OFFSET) << EXP_SHIFT) |  mantissa` below. 


================
Comment at: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp:2130-2132
+// specific to the region to round the values. However, round(double) first
+// calculates the round of the absolute value and then adds the sign back while
+// round(float) directly rounds the value with sign.
----------------
This explains what's going on, but not why. Could you elaborate what's the reason behind double using different algorithm?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59947





More information about the llvm-commits mailing list