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: successors: %bb.0(0x40000000), %bb.1(0x40000000)
19 ; CHECK: %copy:gpr64 = COPY $x0
20 ; CHECK: TBZX %copy, 63, %bb.1
25 successors: %bb.0, %bb.1
27 %copy:gpr(s64) = COPY $x0
28 %negative_one:gpr(s64) = G_CONSTANT i64 -1
29 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s64), %negative_one
30 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
31 G_BRCOND %cmp_trunc(s1), %bb.1
43 ; CHECK-LABEL: name: tbzw_sgt
45 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
46 ; CHECK: %copy:gpr32 = COPY $w0
47 ; CHECK: TBZW %copy, 31, %bb.1
52 successors: %bb.0, %bb.1
54 %copy:gpr(s32) = COPY $w0
55 %negative_one:gpr(s32) = G_CONSTANT i32 -1
56 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s32), %negative_one
57 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
58 G_BRCOND %cmp_trunc(s1), %bb.1
65 name: no_tbz_not_negative_one
70 ; CHECK-LABEL: name: no_tbz_not_negative_one
72 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
73 ; CHECK: %copy:gpr32sp = COPY $w0
74 ; CHECK: [[SUBSWri:%[0-9]+]]:gpr32 = SUBSWri %copy, 1, 0, implicit-def $nzcv
75 ; CHECK: Bcc 12, %bb.1, implicit $nzcv
80 successors: %bb.0, %bb.1
82 %copy:gpr(s32) = COPY $w0
83 %one:gpr(s32) = G_CONSTANT i32 1
84 %cmp:gpr(s32) = G_ICMP intpred(sgt), %copy(s32), %one
85 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
86 G_BRCOND %cmp_trunc(s1), %bb.1
98 ; CHECK-LABEL: name: dont_fold_and
100 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
101 ; CHECK: %copy:gpr64 = COPY $x0
102 ; CHECK: %and:gpr64sp = ANDXri %copy, 8000
103 ; CHECK: [[ADDSXri:%[0-9]+]]:gpr64 = ADDSXri %and, 1, 0, implicit-def $nzcv
104 ; CHECK: Bcc 12, %bb.1, implicit $nzcv
107 ; CHECK: RET_ReallyLR
109 successors: %bb.0, %bb.1
111 %copy:gpr(s64) = COPY $x0
112 %bit:gpr(s64) = G_CONSTANT i64 8
113 %negative_one:gpr(s64) = G_CONSTANT i64 -1
114 %c:gpr(s64) = G_CONSTANT i64 8
115 %and:gpr(s64) = G_AND %copy, %bit
116 %cmp:gpr(s32) = G_ICMP intpred(sgt), %and(s64), %negative_one
117 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
118 G_BRCOND %cmp_trunc(s1), %bb.1
128 regBankSelected: true
130 ; CHECK-LABEL: name: dont_commute
132 ; CHECK: successors: %bb.0(0x40000000), %bb.1(0x40000000)
133 ; CHECK: %copy:gpr64 = COPY $x0
134 ; CHECK: %negative_one:gpr64 = MOVi64imm -1
135 ; CHECK: [[SUBSXrr:%[0-9]+]]:gpr64 = SUBSXrr %negative_one, %copy, implicit-def $nzcv
136 ; CHECK: Bcc 12, %bb.1, implicit $nzcv
139 ; CHECK: RET_ReallyLR
141 successors: %bb.0, %bb.1
143 %copy:gpr(s64) = COPY $x0
144 %negative_one:gpr(s64) = G_CONSTANT i64 -1
145 %cmp:gpr(s32) = G_ICMP intpred(sgt), %negative_one, %copy(s64)
146 %cmp_trunc:gpr(s1) = G_TRUNC %cmp(s32)
147 G_BRCOND %cmp_trunc(s1), %bb.1