Skip to content

Commit 79941c3

Browse files
committed
[X86] lea-2.ll - add test showing failure to fold shl(zext(or(x,c1)),c2) 'addlike' into LEA instruction
1 parent 56396b2 commit 79941c3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

llvm/test/CodeGen/X86/lea-2.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,31 @@ define i32 @test1(i32 %A, i32 %B) {
2626
ret i32 %t4
2727
}
2828

29+
; TODO: The addlike OR instruction should fold into the LEA.
2930

31+
define i64 @test2(i32 %a0, i64 %a1) {
32+
; X32-LABEL: test2:
33+
; X32: # %bb.0:
34+
; X32-NEXT: movl {{[0-9]+}}(%esp), %edx
35+
; X32-NEXT: movl %edx, %eax
36+
; X32-NEXT: andl $2147483640, %eax # imm = 0x7FFFFFF8
37+
; X32-NEXT: shrl $31, %edx
38+
; X32-NEXT: leal 4(%eax,%eax), %eax
39+
; X32-NEXT: addl {{[0-9]+}}(%esp), %eax
40+
; X32-NEXT: adcl {{[0-9]+}}(%esp), %edx
41+
; X32-NEXT: retl
42+
;
43+
; X64-LABEL: test2:
44+
; X64: # %bb.0:
45+
; X64-NEXT: # kill: def $edi killed $edi def $rdi
46+
; X64-NEXT: andl $-8, %edi
47+
; X64-NEXT: orl $2, %edi
48+
; X64-NEXT: leaq (%rsi,%rdi,2), %rax
49+
; X64-NEXT: retq
50+
%x1 = and i32 %a0, -8
51+
%x2 = or i32 %x1, 2
52+
%x3 = zext i32 %x2 to i64
53+
%x4 = shl i64 %x3, 1
54+
%x5 = add i64 %a1, %x4
55+
ret i64 %x5
56+
}

0 commit comments

Comments
 (0)