Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -15527,7 +15527,7 @@
   // This means this is also safe for a signed input and unsigned output, since
   // a negative input would lead to undefined behavior.
   unsigned InputSize = (int)SrcVT.getScalarSizeInBits() - IsInputSigned;
-  unsigned OutputSize = (int)VT.getScalarSizeInBits() - IsOutputSigned;
+  unsigned OutputSize = (int)VT.getScalarSizeInBits();
   unsigned ActualSize = std::min(InputSize, OutputSize);
   const fltSemantics &sem = DAG.EVTToAPFloatSemantics(N0.getValueType());
 
Index: llvm/test/CodeGen/AArch64/float-conv-elim.ll
===================================================================
--- llvm/test/CodeGen/AArch64/float-conv-elim.ll
+++ llvm/test/CodeGen/AArch64/float-conv-elim.ll
@@ -45,10 +45,13 @@
   ret i32 %r
 }
 
+; This requires converting to FP and back.
+
 define i32 @s32_f32_s25_s32(i32 %a) {
 ; CHECK-LABEL: s32_f32_s25_s32:
 ; CHECK:       // %bb.0:
-; CHECK-NEXT:    sbfx w0, w0, #0, #25
+; CHECK-NEXT:    scvtf s0, w0
+; CHECK-NEXT:    fcvtzs w0, s0
 ; CHECK-NEXT:    ret
   %f = sitofp i32 %a to float
   %i = fptosi float %f to i25
@@ -68,10 +71,13 @@
   ret i32 %r
 }
 
+; TODO: This could avoid converting to FP.
+
 define i32 @u32_f32_s25_s32(i32 %a) {
 ; CHECK-LABEL: u32_f32_s25_s32:
 ; CHECK:       // %bb.0:
-; CHECK-NEXT:    sbfx w0, w0, #0, #25
+; CHECK-NEXT:    ucvtf s0, w0
+; CHECK-NEXT:    fcvtzs w0, s0
 ; CHECK-NEXT:    ret
   %f = uitofp i32 %a to float
   %i = fptosi float %f to i25
Index: llvm/test/CodeGen/X86/float-conv-elim.ll
===================================================================
--- llvm/test/CodeGen/X86/float-conv-elim.ll
+++ llvm/test/CodeGen/X86/float-conv-elim.ll
@@ -82,12 +82,13 @@
   ret i32 %r
 }
 
+; This requires converting to FP and back.
+
 define i32 @s32_f32_s25_s32(i32 %a) {
 ; CHECK-LABEL: s32_f32_s25_s32:
 ; CHECK:       # %bb.0:
-; CHECK-NEXT:    movl %edi, %eax
-; CHECK-NEXT:    shll $7, %eax
-; CHECK-NEXT:    sarl $7, %eax
+; CHECK-NEXT:    cvtsi2ss %edi, %xmm0
+; CHECK-NEXT:    cvttss2si %xmm0, %eax
 ; CHECK-NEXT:    retq
   %f = sitofp i32 %a to float
   %i = fptosi float %f to i25
@@ -107,12 +108,14 @@
   ret i32 %r
 }
 
+; TODO: This could avoid converting to FP.
+
 define i32 @u32_f32_s25_s32(i32 %a) {
 ; CHECK-LABEL: u32_f32_s25_s32:
 ; CHECK:       # %bb.0:
 ; CHECK-NEXT:    movl %edi, %eax
-; CHECK-NEXT:    shll $7, %eax
-; CHECK-NEXT:    sarl $7, %eax
+; CHECK-NEXT:    cvtsi2ss %rax, %xmm0
+; CHECK-NEXT:    cvttss2si %xmm0, %eax
 ; CHECK-NEXT:    retq
   %f = uitofp i32 %a to float
   %i = fptosi float %f to i25