1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-unknown-unknown -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s
4 # Test that we can produce a tbz when we have a sgt compare against -1.
6 # The bit tested should be the size of the test register minus 1.
16 ; CHECK-LABEL: name: tbzx_sgt
18 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
19 ; CHECK-NEXT: liveins: $x0
21 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
22 ; CHECK-NEXT: TBZX %copy, 63, %bb.1
26 ; CHECK-NEXT: RET_ReallyLR
28 successors: %bb.0, %bb.1
30 %copy:gpr(s64) = COPY $x0
31 %negative_one:gpr(s64) = G_CONSTANT i64 -1
32 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s64), %negative_one
45 ; CHECK-LABEL: name: tbzw_sgt
47 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
48 ; CHECK-NEXT: liveins: $x0
50 ; CHECK-NEXT: %copy:gpr32 = COPY $w0
51 ; CHECK-NEXT: TBZW %copy, 31, %bb.1
55 ; CHECK-NEXT: RET_ReallyLR
57 successors: %bb.0, %bb.1
59 %copy:gpr(s32) = COPY $w0
60 %negative_one:gpr(s32) = G_CONSTANT i32 -1
61 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s32), %negative_one
69 name: no_tbz_not_negative_one
74 ; CHECK-LABEL: name: no_tbz_not_negative_one
76 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
77 ; CHECK-NEXT: liveins: $x0
79 ; CHECK-NEXT: %copy:gpr32sp = COPY $w0
80 ; CHECK-NEXT: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri %copy, 1, 0, implicit-def $nzcv
81 ; CHECK-NEXT: Bcc 12, %bb.1, implicit $nzcv
85 ; CHECK-NEXT: RET_ReallyLR
87 successors: %bb.0, %bb.1
89 %copy:gpr(s32) = COPY $w0
90 %one:gpr(s32) = G_CONSTANT i32 1
91 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s32), %one
102 regBankSelected: true
104 ; CHECK-LABEL: name: dont_fold_and
106 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
107 ; CHECK-NEXT: liveins: $x0
109 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
110 ; CHECK-NEXT: %and:gpr64sp = ANDXri %copy, 8000
111 ; CHECK-NEXT: [[ADDSXri:%[0-9]+]]:gpr64 = ADDSXri %and, 1, 0, implicit-def $nzcv
112 ; CHECK-NEXT: Bcc 12, %bb.1, implicit $nzcv
113 ; CHECK-NEXT: B %bb.0
116 ; CHECK-NEXT: RET_ReallyLR
118 successors: %bb.0, %bb.1
120 %copy:gpr(s64) = COPY $x0
121 %bit:gpr(s64) = G_CONSTANT i64 8
122 %negative_one:gpr(s64) = G_CONSTANT i64 -1
123 %c:gpr(s64) = G_CONSTANT i64 8
124 %and:gpr(s64) = G_AND %copy, %bit
125 %cmp:gpr(s32) = G_ICMP intpred(sgt), %and(s64), %negative_one
136 regBankSelected: true
138 ; CHECK-LABEL: name: dont_commute
140 ; CHECK-NEXT: successors: %bb.0(0x40000000), %bb.1(0x40000000)
141 ; CHECK-NEXT: liveins: $x0
143 ; CHECK-NEXT: %copy:gpr64 = COPY $x0
144 ; CHECK-NEXT: %negative_one:gpr64 = MOVi64imm -1
145 ; CHECK-NEXT: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr %negative_one, %copy, implicit-def $nzcv
146 ; CHECK-NEXT: Bcc 12, %bb.1, implicit $nzcv
147 ; CHECK-NEXT: B %bb.0
150 ; CHECK-NEXT: RET_ReallyLR
152 successors: %bb.0, %bb.1
154 %copy:gpr(s64) = COPY $x0
155 %negative_one:gpr(s64) = G_CONSTANT i64 -1
156 %cmp:gpr(s32) = G_ICMP intpred(sgt), %negative_one, %copy(s64)