2017-07-27 18:36:09 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s -check-prefix=X64
|
|
|
|
; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s -check-prefix=X86
|
|
|
|
|
|
|
|
define i32 @foo(i32 %a, i32 %b) local_unnamed_addr #0 {
|
|
|
|
; X64-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %entry
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-07-27 18:36:09 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,2), %ecx
|
2017-12-02 06:20:26 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,4), %eax
|
2017-07-27 18:36:09 +08:00
|
|
|
; X64-NEXT: imull %ecx, %eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
;
|
|
|
|
; X86-LABEL: foo:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86: # %bb.0: # %entry
|
2017-07-27 18:36:09 +08:00
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: leal 4(%ecx,%eax,2), %edx
|
|
|
|
; X86-NEXT: leal 4(%ecx,%eax,4), %eax
|
|
|
|
; X86-NEXT: imull %edx, %eax
|
2017-07-27 18:36:09 +08:00
|
|
|
; X86-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%mul = shl i32 %b, 1
|
|
|
|
%add = add i32 %a, 4
|
|
|
|
%add1 = add i32 %add, %mul
|
|
|
|
%mul2 = shl i32 %b, 2
|
|
|
|
%add4 = add i32 %add, %mul2
|
|
|
|
%mul5 = mul nsw i32 %add1, %add4
|
|
|
|
ret i32 %mul5
|
|
|
|
}
|
|
|
|
|
2017-07-31 22:23:28 +08:00
|
|
|
define i32 @foo1(i32 %a, i32 %b) local_unnamed_addr #0 {
|
|
|
|
; X64-LABEL: foo1:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %entry
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,4), %ecx
|
2017-12-02 06:20:26 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,8), %eax
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: imull %ecx, %eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
;
|
|
|
|
; X86-LABEL: foo1:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86: # %bb.0: # %entry
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: leal 4(%ecx,%eax,4), %edx
|
|
|
|
; X86-NEXT: leal 4(%ecx,%eax,8), %eax
|
|
|
|
; X86-NEXT: imull %edx, %eax
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%mul = shl i32 %b, 2
|
|
|
|
%add = add i32 %a, 4
|
|
|
|
%add1 = add i32 %add, %mul
|
|
|
|
%mul2 = shl i32 %b, 3
|
|
|
|
%add4 = add i32 %add, %mul2
|
|
|
|
%mul5 = mul nsw i32 %add1, %add4
|
|
|
|
ret i32 %mul5
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @foo1_mult_basic_blocks(i32 %a, i32 %b) local_unnamed_addr #0 {
|
|
|
|
; X64-LABEL: foo1_mult_basic_blocks:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %entry
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,4), %ecx
|
|
|
|
; X64-NEXT: xorl %eax, %eax
|
|
|
|
; X64-NEXT: cmpl $10, %ecx
|
|
|
|
; X64-NEXT: je .LBB2_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64-NEXT: # %bb.1: # %mid
|
2017-12-02 06:20:26 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,8), %eax
|
|
|
|
; X64-NEXT: imull %eax, %ecx
|
|
|
|
; X64-NEXT: movl %ecx, %eax
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: .LBB2_2: # %exit
|
|
|
|
; X64-NEXT: retq
|
|
|
|
;
|
|
|
|
; X86-LABEL: foo1_mult_basic_blocks:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86: # %bb.0: # %entry
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: pushl %esi
|
|
|
|
; X86-NEXT: .cfi_def_cfa_offset 8
|
|
|
|
; X86-NEXT: .cfi_offset %esi, -8
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
|
|
; X86-NEXT: leal 4(%esi,%edx,4), %ecx
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: xorl %eax, %eax
|
|
|
|
; X86-NEXT: cmpl $10, %ecx
|
|
|
|
; X86-NEXT: je .LBB2_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86-NEXT: # %bb.1: # %mid
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: leal 4(%esi,%edx,8), %eax
|
|
|
|
; X86-NEXT: imull %eax, %ecx
|
|
|
|
; X86-NEXT: movl %ecx, %eax
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: .LBB2_2: # %exit
|
2017-12-02 06:20:26 +08:00
|
|
|
; X86-NEXT: popl %esi
|
2018-04-24 18:32:08 +08:00
|
|
|
; X86-NEXT: .cfi_def_cfa_offset 4
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%mul = shl i32 %b, 2
|
|
|
|
%add = add i32 %a, 4
|
|
|
|
%add1 = add i32 %add, %mul
|
|
|
|
%cmp = icmp ne i32 %add1 , 10
|
|
|
|
br i1 %cmp , label %mid , label %exit
|
|
|
|
mid:
|
|
|
|
%addn = add i32 %a , 4
|
|
|
|
%mul2 = shl i32 %b, 3
|
|
|
|
%add4 = add i32 %addn, %mul2
|
|
|
|
%mul5 = mul nsw i32 %add1, %add4
|
|
|
|
br label %exit
|
|
|
|
|
|
|
|
exit:
|
|
|
|
%retmul = phi i32 [%mul5 , %mid] , [0 , %entry]
|
|
|
|
ret i32 %retmul
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @foo1_mult_basic_blocks_illegal_scale(i32 %a, i32 %b) local_unnamed_addr #0 {
|
|
|
|
; X64-LABEL: foo1_mult_basic_blocks_illegal_scale:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %entry
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $esi killed $esi def $rsi
|
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,2), %ecx
|
|
|
|
; X64-NEXT: xorl %eax, %eax
|
|
|
|
; X64-NEXT: cmpl $10, %ecx
|
|
|
|
; X64-NEXT: je .LBB3_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64-NEXT: # %bb.1: # %mid
|
2017-07-31 22:23:28 +08:00
|
|
|
; X64-NEXT: leal 4(%rdi,%rsi,8), %eax
|
|
|
|
; X64-NEXT: imull %eax, %ecx
|
|
|
|
; X64-NEXT: movl %ecx, %eax
|
|
|
|
; X64-NEXT: .LBB3_2: # %exit
|
|
|
|
; X64-NEXT: retq
|
|
|
|
;
|
|
|
|
; X86-LABEL: foo1_mult_basic_blocks_illegal_scale:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86: # %bb.0: # %entry
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: pushl %esi
|
|
|
|
; X86-NEXT: .cfi_def_cfa_offset 8
|
|
|
|
; X86-NEXT: .cfi_offset %esi, -8
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
|
|
|
|
; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
|
|
|
|
; X86-NEXT: leal 4(%esi,%edx,2), %ecx
|
|
|
|
; X86-NEXT: xorl %eax, %eax
|
|
|
|
; X86-NEXT: cmpl $10, %ecx
|
|
|
|
; X86-NEXT: je .LBB3_2
|
2017-12-05 01:18:51 +08:00
|
|
|
; X86-NEXT: # %bb.1: # %mid
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: leal 4(%esi,%edx,8), %eax
|
|
|
|
; X86-NEXT: imull %eax, %ecx
|
|
|
|
; X86-NEXT: movl %ecx, %eax
|
|
|
|
; X86-NEXT: .LBB3_2: # %exit
|
|
|
|
; X86-NEXT: popl %esi
|
2018-04-24 18:32:08 +08:00
|
|
|
; X86-NEXT: .cfi_def_cfa_offset 4
|
2017-07-31 22:23:28 +08:00
|
|
|
; X86-NEXT: retl
|
|
|
|
entry:
|
|
|
|
%mul = shl i32 %b, 1
|
|
|
|
%add = add i32 %a, 4
|
|
|
|
%add1 = add i32 %add, %mul
|
|
|
|
%cmp = icmp ne i32 %add1 , 10
|
|
|
|
br i1 %cmp, label %mid , label %exit
|
|
|
|
mid:
|
|
|
|
%addn = add i32 %a , 4
|
|
|
|
%mul2 = shl i32 %b, 3
|
|
|
|
%add4 = add i32 %addn, %mul2
|
|
|
|
%mul5 = mul nsw i32 %add1, %add4
|
|
|
|
br label %exit
|
|
|
|
exit:
|
|
|
|
%retmul = phi i32 [%mul5 , %mid] , [0 , %entry]
|
|
|
|
ret i32 %retmul
|
|
|
|
}
|