define i16 @combine_i16_sdiv_pow2(i16 %x) {
; CHECK-LABEL: combine_i16_sdiv_pow2:
; CHECK: # %bb.0:
-; CHECK-NEXT: movswl %di, %eax
-; CHECK-NEXT: shrl $27, %eax
-; CHECK-NEXT: andl $15, %eax
-; CHECK-NEXT: addl %edi, %eax
+; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
+; CHECK-NEXT: leal 15(%rdi), %eax
+; CHECK-NEXT: testw %di, %di
+; CHECK-NEXT: cmovnsl %edi, %eax
; CHECK-NEXT: cwtl
; CHECK-NEXT: shrl $4, %eax
; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
define i16 @combine_i16_sdiv_negpow2(i16 %x) {
; CHECK-LABEL: combine_i16_sdiv_negpow2:
; CHECK: # %bb.0:
-; CHECK-NEXT: movswl %di, %eax
-; CHECK-NEXT: shrl $23, %eax
-; CHECK-NEXT: movzbl %al, %eax
-; CHECK-NEXT: addl %edi, %eax
+; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
+; CHECK-NEXT: leal 255(%rdi), %eax
+; CHECK-NEXT: testw %di, %di
+; CHECK-NEXT: cmovnsl %edi, %eax
; CHECK-NEXT: cwtl
; CHECK-NEXT: sarl $8, %eax
; CHECK-NEXT: negl %eax
; CHECK-LABEL: combine_i16_srem_pow2:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
-; CHECK-NEXT: movswl %ax, %ecx
-; CHECK-NEXT: shrl $27, %ecx
-; CHECK-NEXT: andl $15, %ecx
-; CHECK-NEXT: addl %edi, %ecx
+; CHECK-NEXT: leal 15(%rax), %ecx
+; CHECK-NEXT: testw %ax, %ax
+; CHECK-NEXT: cmovnsl %edi, %ecx
; CHECK-NEXT: andl $-16, %ecx
; CHECK-NEXT: subl %ecx, %eax
-; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
+; CHECK-NEXT: # kill: def $ax killed $ax killed $rax
; CHECK-NEXT: retq
%1 = srem i16 %x, 16
ret i16 %1
; CHECK-LABEL: combine_i16_srem_negpow2:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
-; CHECK-NEXT: movswl %ax, %ecx
-; CHECK-NEXT: shrl $23, %ecx
-; CHECK-NEXT: movzbl %cl, %ecx
-; CHECK-NEXT: addl %edi, %ecx
+; CHECK-NEXT: leal 255(%rax), %ecx
+; CHECK-NEXT: testw %ax, %ax
+; CHECK-NEXT: cmovnsl %edi, %ecx
; CHECK-NEXT: andl $-256, %ecx
; CHECK-NEXT: subl %ecx, %eax
-; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
+; CHECK-NEXT: # kill: def $ax killed $ax killed $rax
; CHECK-NEXT: retq
%1 = srem i16 %x, -256
ret i16 %1