[X86] Add test case for LEA formation regression seen with D60358. NFC

If we have an (add X, (and (aext (shl Y, C1)), C2)), we can pull the shift through and+aext to fold into an LEA with the.
Assuming C1 is small enough and C2 masks off all of the extend bits.

This pattern showed up in D60358. And we need to handle it to prevent a regression.

llvm-svn: 358124
This commit is contained in:
Craig Topper 2019-04-10 19:09:06 +00:00
parent 87a8f9761e
commit cacb70c94b
1 changed files with 19 additions and 0 deletions

View File

@ -75,3 +75,22 @@ entry:
%tmp9 = load i8, i8* %tmp7
ret i8 %tmp9
}
; FIXME should be able to fold shift into address.
define i8 @t6(i8* %X, i32 %i) {
; CHECK-LABEL: t6:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
; CHECK-NEXT: shll $2, %esi
; CHECK-NEXT: andl $60, %esi
; CHECK-NEXT: movb (%rdi,%rsi), %al
; CHECK-NEXT: retq
entry:
%tmp2 = shl i32 %i, 2
%tmp3 = zext i32 %tmp2 to i64
%tmp4 = and i64 %tmp3, 60
%tmp7 = getelementptr i8, i8* %X, i64 %tmp4
%tmp9 = load i8, i8* %tmp7
ret i8 %tmp9
}