OSDN Git Service

[ARM GlobalISel] Add test for BFC. NFCI
authorDiana Picus <diana.picus@linaro.org>
Thu, 22 Nov 2018 09:54:14 +0000 (09:54 +0000)
committerDiana Picus <diana.picus@linaro.org>
Thu, 22 Nov 2018 09:54:14 +0000 (09:54 +0000)
r334871 has made it possible for TableGen'erated code to select BFC, but
it has not added a test for it on the ARM side. Add it now to make sure
we don't introduce regressions if we ever change anything about that
rule.

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

test/CodeGen/ARM/GlobalISel/arm-instruction-select-combos.mir

index b361023..d3e9796 100644 (file)
@@ -42,6 +42,9 @@
 
   define void @test_vfnmss() #4 { ret void }
 
+  define void @test_bfc() #2 { ret void }
+  define void @test_no_bfc_bad_mask() #2 { ret void }
+
   attributes #0 = { "target-features"="+v6" }
   attributes #1 = { "target-features"="-v6" }
   attributes #2 = { "target-features"="+v6t2" }
@@ -1142,3 +1145,57 @@ body:             |
     BX_RET 14, $noreg, implicit $s0
     ; CHECK: BX_RET 14, $noreg, implicit $s0
 ...
+---
+name:            test_bfc
+# CHECK-LABEL: name: test_bfc
+legalized:       true
+regBankSelected: true
+selected:        false
+# CHECK: selected: true
+registers:
+  - { id: 0, class: gprb }
+  - { id: 1, class: gprb }
+  - { id: 2, class: gprb }
+body:             |
+  bb.0:
+    liveins: $r0
+
+    %0(s32) = COPY $r0
+    %1(s32) = G_CONSTANT i32 -65529 ; 0xFFFF0007
+    %2(s32) = G_AND %0, %1
+    ; CHECK: [[RS:%[0-9]+]]:gpr = COPY $r0
+    ; CHECK: [[RD:%[0-9]+]]:gpr = BFC [[RS]], -65529, 14, $noreg
+
+    $r0 = COPY %2(s32)
+    ; CHECK: $r0 = COPY [[RD]]
+
+    BX_RET 14, $noreg, implicit $r0
+    ; CHECK: BX_RET 14, $noreg, implicit $r0
+...
+---
+name:            test_no_bfc_bad_mask
+# CHECK-LABEL: name: test_no_bfc_bad_mask
+legalized:       true
+regBankSelected: true
+selected:        false
+# CHECK: selected: true
+registers:
+  - { id: 0, class: gprb }
+  - { id: 1, class: gprb }
+  - { id: 2, class: gprb }
+body:             |
+  bb.0:
+    liveins: $r0
+
+    %0(s32) = COPY $r0
+    %1(s32) = G_CONSTANT i32 6 ; 0x00000006
+    %2(s32) = G_AND %0, %1
+    ; CHECK: [[RS:%[0-9]+]]:gpr = COPY $r0
+    ; CHECK-NOT: BFC
+
+    $r0 = COPY %2(s32)
+    ; CHECK: $r0 = COPY [[RD]]
+
+    BX_RET 14, $noreg, implicit $r0
+    ; CHECK: BX_RET 14, $noreg, implicit $r0
+...