Skip to content

Commit 0182a21

Browse files
committed
fixup! [M68k] Fix backwards BTST condition
Add a CodeGen test case for lowering AND mask to BTST
1 parent 38b12ec commit 0182a21

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

llvm/test/CodeGen/M68k/Bits/btst.ll

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc < %s -mtriple=m68k-freestanding -verify-machineinstrs | FileCheck %s
33

4-
define fastcc i16 @test1(i16 %a) nounwind {
5-
; CHECK-LABEL: test1:
4+
define fastcc i16 @switch_to_btst(i16 %a) nounwind {
5+
; CHECK-LABEL: switch_to_btst:
66
; CHECK: ; %bb.0: ; %entry
77
; CHECK-NEXT: move.l %d0, %d1
88
; CHECK-NEXT: and.l #65535, %d1
@@ -35,3 +35,28 @@ define fastcc i16 @test1(i16 %a) nounwind {
3535
no_match:
3636
ret i16 0
3737
}
38+
39+
define fastcc i16 @and_mask_to_btst(i8 %a, i8 %b) nounwind {
40+
; CHECK-LABEL: and_mask_to_btst:
41+
; CHECK: ; %bb.0:
42+
; CHECK-NEXT: and.l #7, %d1
43+
; CHECK-NEXT: btst %d1, %d0
44+
; CHECK-NEXT: beq .LBB1_1
45+
; CHECK-NEXT: ; %bb.2: ; %cond_false
46+
; CHECK-NEXT: moveq #0, %d0
47+
; CHECK-NEXT: rts
48+
; CHECK-NEXT: .LBB1_1: ; %cond_true
49+
; CHECK-NEXT: moveq #1, %d0
50+
; CHECK-NEXT: rts
51+
%33 = and i8 %b, 7
52+
%34 = shl nuw i8 1, %33
53+
%35 = and i8 %34, %a
54+
%.not = icmp eq i8 %35, 0
55+
br i1 %.not, label %cond_true, label %cond_false
56+
57+
cond_true:
58+
ret i16 1
59+
60+
cond_false:
61+
ret i16 0
62+
}

0 commit comments

Comments
 (0)