Skip to content

Commit c3b7894

Browse files
committed
[X86] Add test case for #124871. NFC
This shows missed opportunity to fold (fshl ld1, ld0, c) -> (ld0[ofs]) if the load chain results are used.
1 parent e269c2b commit c3b7894

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

llvm/test/CodeGen/X86/fshl.ll

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,60 @@ define i64 @combine_fshl_load_i64(ptr %p) nounwind {
657657
ret i64 %res
658658
}
659659

660+
define i16 @combine_fshl_load_i16_chain_use(ptr %p, ptr %q, i16 %r) nounwind {
661+
; X86-FAST-LABEL: combine_fshl_load_i16_chain_use:
662+
; X86-FAST: # %bb.0:
663+
; X86-FAST-NEXT: pushl %esi
664+
; X86-FAST-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
665+
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %edx
666+
; X86-FAST-NEXT: movl {{[0-9]+}}(%esp), %eax
667+
; X86-FAST-NEXT: movzwl (%eax), %esi
668+
; X86-FAST-NEXT: movzwl 2(%eax), %eax
669+
; X86-FAST-NEXT: shldw $8, %si, %ax
670+
; X86-FAST-NEXT: movw %cx, (%edx)
671+
; X86-FAST-NEXT: popl %esi
672+
; X86-FAST-NEXT: retl
673+
;
674+
; X86-SLOW-LABEL: combine_fshl_load_i16_chain_use:
675+
; X86-SLOW: # %bb.0:
676+
; X86-SLOW-NEXT: pushl %esi
677+
; X86-SLOW-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
678+
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %edx
679+
; X86-SLOW-NEXT: movl {{[0-9]+}}(%esp), %esi
680+
; X86-SLOW-NEXT: movzwl 2(%esi), %eax
681+
; X86-SLOW-NEXT: movzbl 1(%esi), %esi
682+
; X86-SLOW-NEXT: shll $8, %eax
683+
; X86-SLOW-NEXT: orl %esi, %eax
684+
; X86-SLOW-NEXT: movw %cx, (%edx)
685+
; X86-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
686+
; X86-SLOW-NEXT: popl %esi
687+
; X86-SLOW-NEXT: retl
688+
;
689+
; X64-FAST-LABEL: combine_fshl_load_i16_chain_use:
690+
; X64-FAST: # %bb.0:
691+
; X64-FAST-NEXT: movzwl (%rdi), %ecx
692+
; X64-FAST-NEXT: movzwl 2(%rdi), %eax
693+
; X64-FAST-NEXT: shldw $8, %cx, %ax
694+
; X64-FAST-NEXT: movw %dx, (%rsi)
695+
; X64-FAST-NEXT: retq
696+
;
697+
; X64-SLOW-LABEL: combine_fshl_load_i16_chain_use:
698+
; X64-SLOW: # %bb.0:
699+
; X64-SLOW-NEXT: movzwl 2(%rdi), %eax
700+
; X64-SLOW-NEXT: movzbl 1(%rdi), %ecx
701+
; X64-SLOW-NEXT: shll $8, %eax
702+
; X64-SLOW-NEXT: orl %ecx, %eax
703+
; X64-SLOW-NEXT: movw %dx, (%rsi)
704+
; X64-SLOW-NEXT: # kill: def $ax killed $ax killed $eax
705+
; X64-SLOW-NEXT: retq
706+
%p1 = getelementptr i16, ptr %p, i32 1
707+
%ld0 = load i16, ptr %p
708+
%ld1 = load i16, ptr %p1
709+
%res = call i16 @llvm.fshl.i16(i16 %ld1, i16 %ld0, i16 8)
710+
store i16 %r, ptr %q
711+
ret i16 %res
712+
}
713+
660714
!llvm.module.flags = !{!0}
661715
!0 = !{i32 1, !"ProfileSummary", !1}
662716
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}

0 commit comments

Comments
 (0)