@@ -6848,32 +6848,32 @@ static SDValue lowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG,
6848
6848
SDLoc DL(Op);
6849
6849
6850
6850
// Get sign bit into an integer value.
6851
- SDValue SignAsInt;
6852
6851
unsigned SignSize = Sign.getValueSizeInBits();
6853
- if (SignSize == Subtarget.getXLen()) {
6854
- SignAsInt = DAG.getNode(ISD::BITCAST, DL, XLenVT, Sign);
6855
- } else if (SignSize == 16) {
6856
- SignAsInt = DAG.getNode(RISCVISD::FMV_X_ANYEXTH, DL, XLenVT, Sign);
6857
- } else if (SignSize == 32) {
6858
- SignAsInt = DAG.getNode(RISCVISD::FMV_X_ANYEXTW_RV64, DL, XLenVT, Sign);
6859
- } else if (SignSize == 64) {
6860
- assert(XLenVT == MVT::i32 && "Unexpected type");
6861
- // Copy the upper word to integer.
6862
- SignAsInt = DAG.getNode(RISCVISD::SplitF64, DL, {MVT::i32, MVT::i32}, Sign)
6863
- .getValue(1);
6864
- SignSize = 32;
6865
- } else
6866
- llvm_unreachable("Unexpected sign size");
6852
+ SDValue SignAsInt = [&]() {
6853
+ if (SignSize == Subtarget.getXLen())
6854
+ return DAG.getNode(ISD::BITCAST, DL, XLenVT, Sign);
6855
+ switch (SignSize) {
6856
+ case 16:
6857
+ return DAG.getNode(RISCVISD::FMV_X_ANYEXTH, DL, XLenVT, Sign);
6858
+ case 32:
6859
+ return DAG.getNode(RISCVISD::FMV_X_ANYEXTW_RV64, DL, XLenVT, Sign);
6860
+ case 64: {
6861
+ assert(XLenVT == MVT::i32 && "Unexpected type");
6862
+ // Copy the upper word to integer.
6863
+ SignSize = 32;
6864
+ return DAG.getNode(RISCVISD::SplitF64, DL, {MVT::i32, MVT::i32}, Sign)
6865
+ .getValue(1);
6866
+ }
6867
+ default:
6868
+ llvm_unreachable("Unexpected sign size");
6869
+ }
6870
+ }();
6867
6871
6868
6872
// Get the signbit at the right position for MagAsInt.
6869
- int ShiftAmount = (int)SignSize - (int)Mag.getValueSizeInBits();
6870
- if (ShiftAmount > 0) {
6871
- SignAsInt = DAG.getNode(ISD::SRL, DL, XLenVT, SignAsInt,
6872
- DAG.getConstant(ShiftAmount, DL, XLenVT));
6873
- } else if (ShiftAmount < 0) {
6874
- SignAsInt = DAG.getNode(ISD::SHL, DL, XLenVT, SignAsInt,
6875
- DAG.getConstant(-ShiftAmount, DL, XLenVT));
6876
- }
6873
+ if (int ShiftAmount = (int)SignSize - (int)Mag.getValueSizeInBits())
6874
+ SignAsInt = DAG.getNode(ShiftAmount > 0 ? ISD::SRL : ISD::SHL, DL, XLenVT,
6875
+ SignAsInt,
6876
+ DAG.getConstant(std::abs(ShiftAmount), DL, XLenVT));
6877
6877
6878
6878
// Mask the sign bit and any bits above it. The extra bits will be dropped
6879
6879
// when we convert back to FP.
0 commit comments