llvm.org GIT mirror llvm / f0c31a6
[X86][Codegen] Add missed pattern that may be a lea+neg git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362886 91177308-0d34-0410-b5e6-96231b3b80d8 Roman Lebedev 4 months ago
1 changed file(s) with 86 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc < %s -mtriple=i686-- -mattr=+slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,X86,SLOW,SLOW-X86
2 ; RUN: llc < %s -mtriple=i686-- -mattr=-slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,X86,FAST,FAST-X86
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,X64,SLOW,SLOW-X64
4 ; RUN: llc < %s -mtriple=x86_64-- -mattr=-slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,X64,FAST,FAST-X64
5
6 ; )32-a)-b --> 32-(a+b) --> -(a+b)+32 --> -((a+b)-32) -> -(a+b+(-32))
7
8 define i32 @t0(i32 %a, i32 %b) {
9 ; X86-LABEL: t0:
10 ; X86: # %bb.0:
11 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
12 ; X86-NEXT: addl {{[0-9]+}}(%esp), %ecx
13 ; X86-NEXT: movl $32, %eax
14 ; X86-NEXT: subl %ecx, %eax
15 ; X86-NEXT: retl
16 ;
17 ; X64-LABEL: t0:
18 ; X64: # %bb.0:
19 ; X64-NEXT: addl %esi, %edi
20 ; X64-NEXT: movl $32, %eax
21 ; X64-NEXT: subl %edi, %eax
22 ; X64-NEXT: retq
23 %t0 = sub i32 32, %a
24 %r = sub i32 %t0, %b
25 ret i32 %r
26 }
27 define i32 @t1(i32 %a, i32 %b) {
28 ; X86-LABEL: t1:
29 ; X86: # %bb.0:
30 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
31 ; X86-NEXT: addl {{[0-9]+}}(%esp), %ecx
32 ; X86-NEXT: movl $32, %eax
33 ; X86-NEXT: subl %ecx, %eax
34 ; X86-NEXT: retl
35 ;
36 ; X64-LABEL: t1:
37 ; X64: # %bb.0:
38 ; X64-NEXT: addl %esi, %edi
39 ; X64-NEXT: movl $32, %eax
40 ; X64-NEXT: subl %edi, %eax
41 ; X64-NEXT: retq
42 %t0 = add i32 %a, %b
43 %r = sub i32 32, %t0
44 ret i32 %r
45 }
46 define i32 @t2(i32 %a, i32 %b) {
47 ; X86-LABEL: t2:
48 ; X86: # %bb.0:
49 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
50 ; X86-NEXT: addl {{[0-9]+}}(%esp), %ecx
51 ; X86-NEXT: movl $32, %eax
52 ; X86-NEXT: subl %ecx, %eax
53 ; X86-NEXT: retl
54 ;
55 ; X64-LABEL: t2:
56 ; X64: # %bb.0:
57 ; X64-NEXT: addl %esi, %edi
58 ; X64-NEXT: movl $32, %eax
59 ; X64-NEXT: subl %edi, %eax
60 ; X64-NEXT: retq
61 %t0 = add i32 %a, %b
62 %t1 = sub i32 0, %t0
63 %r = add i32 %t1, 32
64 ret i32 %r
65 }
66 define i32 @t3(i32 %a, i32 %b) {
67 ; X86-LABEL: t3:
68 ; X86: # %bb.0:
69 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
70 ; X86-NEXT: addl {{[0-9]+}}(%esp), %ecx
71 ; X86-NEXT: movl $32, %eax
72 ; X86-NEXT: subl %ecx, %eax
73 ; X86-NEXT: retl
74 ;
75 ; X64-LABEL: t3:
76 ; X64: # %bb.0:
77 ; X64-NEXT: addl %esi, %edi
78 ; X64-NEXT: movl $32, %eax
79 ; X64-NEXT: subl %edi, %eax
80 ; X64-NEXT: retq
81 %t0 = add i32 %a, %b
82 %t1 = sub i32 %t0, 32
83 %r = sub i32 0, %t1
84 ret i32 %r
85 }