[AArch64] Check the expansion of BITREVERSE in regression test
authorJames Molloy <james.molloy@arm.com>
Fri, 13 Nov 2015 10:05:31 +0000 (10:05 +0000)
committerJames Molloy <james.molloy@arm.com>
Fri, 13 Nov 2015 10:05:31 +0000 (10:05 +0000)
Something I missed from Hal's review, rightly pointed out by Ben Kramer - we should make sure the expansion is properly checked as it can be easy for bugs to creep in.

I've checked the scalar i8 expansion here and the vector i8 expansion in a previous commit.

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

test/CodeGen/AArch64/bitreverse.ll

index 702581789bb7a9c35c87588770b31cee3d2e3be3..936e3554b397fe4a978784b742c4e63e60ff6aff 100644 (file)
@@ -14,10 +14,29 @@ define <2 x i16> @f(<2 x i16> %a) {
 
 declare i8 @llvm.bitreverse.i8(i8) readnone
 
+; Unfortunately some of the shift-and-inserts become BFIs, and some do not :(
 define i8 @g(i8 %a) {
 ; CHECK-LABEL: g:
-; CHECK: lsl
-; CHECK: and
+; CHECK-DAG: lsr [[S5:w.*]], w0, #5
+; CHECK-DAG: lsr [[S4:w.*]], w0, #4
+; CHECK-DAG: lsr [[S3:w.*]], w0, #3
+; CHECK-DAG: lsr [[S2:w.*]], w0, #2
+; CHECK-DAG: lsl [[L1:w.*]], w0, #29
+; CHECK-DAG: lsl [[L2:w.*]], w0, #19
+; CHECK-DAG: lsl [[L3:w.*]], w0, #17
+
+; CHECK-DAG: and [[T1:w.*]], [[L1]], #0x40000000
+; CHECK-DAG: bfi [[T1]], w0, #31, #1
+; CHECK-DAG: bfi [[T1]], [[S2]], #29, #1
+; CHECK-DAG: bfi [[T1]], [[S3]], #28, #1
+; CHECK-DAG: bfi [[T1]], [[S4]], #27, #1
+; CHECK-DAG: bfi [[T1]], [[S5]], #26, #1
+; CHECK-DAG: and [[T2:w.*]], [[L2]], #0x2000000
+; CHECK-DAG: and [[T3:w.*]], [[L3]], #0x1000000
+; CHECK-DAG: orr [[T4:w.*]], [[T1]], [[T2]]
+; CHECK-DAG: orr [[T5:w.*]], [[T4]], [[T3]]
+; CHECK:     lsr w0, [[T5]], #24
+
   %b = call i8 @llvm.bitreverse.i8(i8 %a)
   ret i8 %b
 }