184 lines · plain
1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2 3# RUN: llc -mtriple aarch64 -debugify-and-strip-all-safe -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s4 5...6---7name: fold_scalar8tracksRegLiveness: true9body: |10 bb.0:11 liveins: $w0, $w112 ; (xor (and x, y), y) -> (and (not x), y)13 ; CHECK-LABEL: name: fold_scalar14 ; CHECK: liveins: $w0, $w115 ; CHECK-NEXT: {{ $}}16 ; CHECK-NEXT: %x:_(s32) = COPY $w017 ; CHECK-NEXT: %y:_(s32) = COPY $w118 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -119 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]20 ; CHECK-NEXT: %xor:_(s32) = G_AND [[XOR]], %y21 ; CHECK-NEXT: $w0 = COPY %xor(s32)22 ; CHECK-NEXT: RET_ReallyLR implicit $w023 %x:_(s32) = COPY $w024 %y:_(s32) = COPY $w125 %and:_(s32) = G_AND %x, %y26 %xor:_(s32) = G_XOR %and, %y27 $w0 = COPY %xor(s32)28 RET_ReallyLR implicit $w029 30...31---32name: fold_vector33tracksRegLiveness: true34body: |35 bb.0:36 liveins: $x0, $x137 ; Vector edition38 ; CHECK-LABEL: name: fold_vector39 ; CHECK: liveins: $x0, $x140 ; CHECK-NEXT: {{ $}}41 ; CHECK-NEXT: %x:_(<2 x s32>) = COPY $x042 ; CHECK-NEXT: %y:_(<2 x s32>) = COPY $x143 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -144 ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[C]](s32), [[C]](s32)45 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<2 x s32>) = G_XOR %x, [[BUILD_VECTOR]]46 ; CHECK-NEXT: %xor:_(<2 x s32>) = G_AND [[XOR]], %y47 ; CHECK-NEXT: $x0 = COPY %xor(<2 x s32>)48 ; CHECK-NEXT: RET_ReallyLR implicit $x049 %x:_(<2 x s32>) = COPY $x050 %y:_(<2 x s32>) = COPY $x151 %and:_(<2 x s32>) = G_AND %x, %y52 %xor:_(<2 x s32>) = G_XOR %and, %y53 $x0 = COPY %xor(<2 x s32>)54 RET_ReallyLR implicit $x055 56...57---58name: fold_commuted_and59tracksRegLiveness: true60body: |61 bb.0:62 liveins: $w0, $w163 ; (xor (and y, x), y) -> (and (not x), y)64 ; CHECK-LABEL: name: fold_commuted_and65 ; CHECK: liveins: $w0, $w166 ; CHECK-NEXT: {{ $}}67 ; CHECK-NEXT: %x:_(s32) = COPY $w068 ; CHECK-NEXT: %y:_(s32) = COPY $w169 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -170 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]71 ; CHECK-NEXT: %xor:_(s32) = G_AND [[XOR]], %y72 ; CHECK-NEXT: $w0 = COPY %xor(s32)73 ; CHECK-NEXT: RET_ReallyLR implicit $w074 %x:_(s32) = COPY $w075 %y:_(s32) = COPY $w176 %and:_(s32) = G_AND %y, %x77 %xor:_(s32) = G_XOR %and, %y78 $w0 = COPY %xor(s32)79 RET_ReallyLR implicit $w080 81...82---83name: fold_commuted_xor84tracksRegLiveness: true85body: |86 bb.0:87 liveins: $w0, $w188 ; (xor y, (and x, y)) -> (and (not x), y)89 ; CHECK-LABEL: name: fold_commuted_xor90 ; CHECK: liveins: $w0, $w191 ; CHECK-NEXT: {{ $}}92 ; CHECK-NEXT: %x:_(s32) = COPY $w093 ; CHECK-NEXT: %y:_(s32) = COPY $w194 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -195 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]96 ; CHECK-NEXT: %xor:_(s32) = G_AND [[XOR]], %y97 ; CHECK-NEXT: $w0 = COPY %xor(s32)98 ; CHECK-NEXT: RET_ReallyLR implicit $w099 %x:_(s32) = COPY $w0100 %y:_(s32) = COPY $w1101 %and:_(s32) = G_AND %x, %y102 %xor:_(s32) = G_XOR %y, %and103 $w0 = COPY %xor(s32)104 RET_ReallyLR implicit $w0105 106...107---108name: fold_commuted_xor_and109tracksRegLiveness: true110body: |111 bb.0:112 liveins: $w0, $w1113 ; (xor y, (and x, y)) -> (and (not x), y)114 ; CHECK-LABEL: name: fold_commuted_xor_and115 ; CHECK: liveins: $w0, $w1116 ; CHECK-NEXT: {{ $}}117 ; CHECK-NEXT: %x:_(s32) = COPY $w0118 ; CHECK-NEXT: %y:_(s32) = COPY $w1119 ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1120 ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(s32) = G_XOR %x, [[C]]121 ; CHECK-NEXT: %xor:_(s32) = G_AND [[XOR]], %y122 ; CHECK-NEXT: $w0 = COPY %xor(s32)123 ; CHECK-NEXT: RET_ReallyLR implicit $w0124 %x:_(s32) = COPY $w0125 %y:_(s32) = COPY $w1126 %and:_(s32) = G_AND %y, %x127 %xor:_(s32) = G_XOR %y, %and128 $w0 = COPY %xor(s32)129 RET_ReallyLR implicit $w0130 131...132---133name: dont_fold_different_regs134tracksRegLiveness: true135body: |136 bb.0:137 liveins: $w0, $w1, $w2138 ; The G_AND does not share any registers with the G_XOR139 ; CHECK-LABEL: name: dont_fold_different_regs140 ; CHECK: liveins: $w0, $w1, $w2141 ; CHECK-NEXT: {{ $}}142 ; CHECK-NEXT: %x:_(s32) = COPY $w0143 ; CHECK-NEXT: %y:_(s32) = COPY $w1144 ; CHECK-NEXT: %z:_(s32) = COPY $w2145 ; CHECK-NEXT: %and:_(s32) = G_AND %x, %z146 ; CHECK-NEXT: %xor:_(s32) = G_XOR %and, %y147 ; CHECK-NEXT: $w0 = COPY %xor(s32)148 ; CHECK-NEXT: RET_ReallyLR implicit $w0149 %x:_(s32) = COPY $w0150 %y:_(s32) = COPY $w1151 %z:_(s32) = COPY $w2152 %and:_(s32) = G_AND %x, %z153 %xor:_(s32) = G_XOR %and, %y154 $w0 = COPY %xor(s32)155 RET_ReallyLR implicit $w0156 157...158---159name: dont_fold_more_than_one_use160tracksRegLiveness: true161body: |162 bb.0:163 liveins: $w0, $w1, $w2164 ; Don't fold when the G_AND is used outside the G_XOR.165 ; CHECK-LABEL: name: dont_fold_more_than_one_use166 ; CHECK: liveins: $w0, $w1, $w2167 ; CHECK-NEXT: {{ $}}168 ; CHECK-NEXT: %x:_(s32) = COPY $w0169 ; CHECK-NEXT: %y:_(s32) = COPY $w1170 ; CHECK-NEXT: %z:_(s32) = COPY $w2171 ; CHECK-NEXT: %and:_(s32) = G_AND %x, %z172 ; CHECK-NEXT: %xor:_(s32) = G_XOR %and, %y173 ; CHECK-NEXT: %add:_(s32) = G_ADD %and, %xor174 ; CHECK-NEXT: $w0 = COPY %add(s32)175 ; CHECK-NEXT: RET_ReallyLR implicit $w0176 %x:_(s32) = COPY $w0177 %y:_(s32) = COPY $w1178 %z:_(s32) = COPY $w2179 %and:_(s32) = G_AND %x, %z180 %xor:_(s32) = G_XOR %and, %y181 %add:_(s32) = G_ADD %and, %xor182 $w0 = COPY %add(s32)183 RET_ReallyLR implicit $w0184