]> granicus.if.org Git - llvm/commitdiff
[X86] Add test case for LEA formation regression seen with D60358. NFC
authorCraig Topper <craig.topper@intel.com>
Wed, 10 Apr 2019 19:09:06 +0000 (19:09 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 10 Apr 2019 19:09:06 +0000 (19:09 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358124 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/X86/fold-and-shift-x86_64.ll

index ead180edc97ce0531410fbcf332fa2991c0566f8..5413e1bb1b39de5a67d97eb55354ffe53d64630f 100644 (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
+}
+