[llvm] bd469e8 - [SDAG] Minor cleanup to TargetLowering::expandFP_ROUND. NFC (#193793)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 24 01:24:12 PDT 2026


Author: David Green
Date: 2026-04-24T09:24:07+01:00
New Revision: bd469e8a1d4768b278182aa982763128d40e7e90

URL: https://github.com/llvm/llvm-project/commit/bd469e8a1d4768b278182aa982763128d40e7e90
DIFF: https://github.com/llvm/llvm-project/commit/bd469e8a1d4768b278182aa982763128d40e7e90.diff

LOG: [SDAG] Minor cleanup to TargetLowering::expandFP_ROUND. NFC (#193793)

Noticed when porting to GISel, constants might as well be added to the
RHS of an add and a bitcast from the same type can be removed.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 9150efe350c15..f37ea127dd357 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -12546,7 +12546,7 @@ SDValue TargetLowering::expandFP_ROUND(SDNode *Node, SelectionDAG &DAG) const {
                               DAG.getShiftAmountConstant(16, I32, dl));
     Lsb = DAG.getNode(ISD::AND, dl, I32, Lsb, One);
     SDValue RoundingBias =
-        DAG.getNode(ISD::ADD, dl, I32, DAG.getConstant(0x7fff, dl, I32), Lsb);
+        DAG.getNode(ISD::ADD, dl, I32, Lsb, DAG.getConstant(0x7fff, dl, I32));
     SDValue Add = DAG.getNode(ISD::ADD, dl, I32, Op, RoundingBias);
 
     // Don't round if we had a NaN, we don't want to turn 0x7fffffff into
@@ -12556,7 +12556,6 @@ SDValue TargetLowering::expandFP_ROUND(SDNode *Node, SelectionDAG &DAG) const {
     // Now that we have rounded, shift the bits into position.
     Op = DAG.getNode(ISD::SRL, dl, I32, Op,
                      DAG.getShiftAmountConstant(16, I32, dl));
-    Op = DAG.getNode(ISD::BITCAST, dl, I32, Op);
     EVT I16 = I32.changeElementType(*DAG.getContext(), MVT::i16);
     Op = DAG.getNode(ISD::TRUNCATE, dl, I16, Op);
     return DAG.getNode(ISD::BITCAST, dl, VT, Op);


        


More information about the llvm-commits mailing list