|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +; PR125228 |
| 5 | + |
| 6 | +define <16 x i8> @knownbits_bitcast_masked_shift(<16 x i8> %arg) { |
| 7 | +; CHECK-LABEL: define <16 x i8> @knownbits_bitcast_masked_shift( |
| 8 | +; CHECK-SAME: <16 x i8> [[ARG:%.*]]) { |
| 9 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[ARG]] to <8 x i16> |
| 10 | +; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST]], splat (i16 4) |
| 11 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8> |
| 12 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST1]], splat (i8 3) |
| 13 | +; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST]], splat (i16 4) |
| 14 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 15 | +; CHECK-NEXT: [[AND3:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 48) |
| 16 | +; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND3]] |
| 17 | +; CHECK-NEXT: [[BITCAST4:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16> |
| 18 | +; CHECK-NEXT: [[SHL5:%.*]] = shl nuw <8 x i16> [[BITCAST4]], splat (i16 2) |
| 19 | +; CHECK-NEXT: [[BITCAST6:%.*]] = bitcast <8 x i16> [[SHL5]] to <16 x i8> |
| 20 | +; CHECK-NEXT: [[AND7:%.*]] = and <16 x i8> [[BITCAST6]], splat (i8 -4) |
| 21 | +; CHECK-NEXT: ret <16 x i8> [[AND7]] |
| 22 | +; |
| 23 | + %bitcast = bitcast <16 x i8> %arg to <8 x i16> |
| 24 | + %lshr = lshr <8 x i16> %bitcast, splat (i16 4) |
| 25 | + %bitcast1 = bitcast <8 x i16> %lshr to <16 x i8> |
| 26 | + %and = and <16 x i8> %bitcast1, splat (i8 3) |
| 27 | + %shl = shl <8 x i16> %bitcast, splat (i16 4) |
| 28 | + %bitcast2 = bitcast <8 x i16> %shl to <16 x i8> |
| 29 | + %and3 = and <16 x i8> %bitcast2, splat (i8 48) |
| 30 | + %or = or disjoint <16 x i8> %and, %and3 |
| 31 | + %bitcast4 = bitcast <16 x i8> %or to <8 x i16> |
| 32 | + %shl5 = shl nuw <8 x i16> %bitcast4, splat (i16 2) |
| 33 | + %bitcast6 = bitcast <8 x i16> %shl5 to <16 x i8> |
| 34 | + %and7 = and <16 x i8> %bitcast6, splat (i8 -4) |
| 35 | + ret <16 x i8> %and7 |
| 36 | +} |
| 37 | + |
| 38 | +define <16 x i8> @knownbits_shuffle_bitcast_masked_shift(<8 x i16> %arg) { |
| 39 | +; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_bitcast_masked_shift( |
| 40 | +; CHECK-SAME: <8 x i16> [[ARG:%.*]]) { |
| 41 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8> |
| 42 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14> |
| 43 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 44 | +; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4) |
| 45 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8> |
| 46 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 3) |
| 47 | +; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4) |
| 48 | +; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 49 | +; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 48) |
| 50 | +; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND4]] |
| 51 | +; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16> |
| 52 | +; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2) |
| 53 | +; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8> |
| 54 | +; CHECK-NEXT: [[AND8:%.*]] = and <16 x i8> [[BITCAST7]], splat (i8 -4) |
| 55 | +; CHECK-NEXT: ret <16 x i8> [[AND8]] |
| 56 | +; |
| 57 | + %bitcast = bitcast <8 x i16> %arg to <16 x i8> |
| 58 | + %shufflevector = shufflevector <16 x i8> %bitcast, <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14> |
| 59 | + %bitcast1 = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 60 | + %lshr = lshr <8 x i16> %bitcast1, splat (i16 4) |
| 61 | + %bitcast2 = bitcast <8 x i16> %lshr to <16 x i8> |
| 62 | + %and = and <16 x i8> %bitcast2, splat (i8 3) |
| 63 | + %shl = shl <8 x i16> %bitcast1, splat (i16 4) |
| 64 | + %bitcast3 = bitcast <8 x i16> %shl to <16 x i8> |
| 65 | + %and4 = and <16 x i8> %bitcast3, splat (i8 48) |
| 66 | + %or = or disjoint <16 x i8> %and, %and4 |
| 67 | + %bitcast5 = bitcast <16 x i8> %or to <8 x i16> |
| 68 | + %shl6 = shl nuw <8 x i16> %bitcast5, splat (i16 2) |
| 69 | + %bitcast7 = bitcast <8 x i16> %shl6 to <16 x i8> |
| 70 | + %and8 = and <16 x i8> %bitcast7, splat (i8 -4) |
| 71 | + ret <16 x i8> %and8 |
| 72 | +} |
| 73 | + |
| 74 | +define <16 x i8> @knownbits_shuffle_masked_nibble_shift(<8 x i16> %arg) { |
| 75 | +; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_masked_nibble_shift( |
| 76 | +; CHECK-SAME: <8 x i16> [[ARG:%.*]]) { |
| 77 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8> |
| 78 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST]], splat (i8 15) |
| 79 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[AND]], <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14> |
| 80 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 81 | +; CHECK-NEXT: [[SHL:%.*]] = shl nuw <8 x i16> [[BITCAST1]], splat (i16 4) |
| 82 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 83 | +; CHECK-NEXT: [[AND3:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 -16) |
| 84 | +; CHECK-NEXT: ret <16 x i8> [[AND3]] |
| 85 | +; |
| 86 | + %bitcast = bitcast <8 x i16> %arg to <16 x i8> |
| 87 | + %and = and <16 x i8> %bitcast, splat (i8 15) |
| 88 | + %shufflevector = shufflevector <16 x i8> %and, <16 x i8> poison, <16 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14> |
| 89 | + %bitcast1 = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 90 | + %shl = shl nuw <8 x i16> %bitcast1, splat (i16 4) |
| 91 | + %bitcast2 = bitcast <8 x i16> %shl to <16 x i8> |
| 92 | + %and3 = and <16 x i8> %bitcast2, splat (i8 -16) |
| 93 | + ret <16 x i8> %and3 |
| 94 | +} |
| 95 | + |
| 96 | +define <16 x i8> @knownbits_reverse_shuffle_masked_shift(<8 x i16> %arg) { |
| 97 | +; CHECK-LABEL: define <16 x i8> @knownbits_reverse_shuffle_masked_shift( |
| 98 | +; CHECK-SAME: <8 x i16> [[ARG:%.*]]) { |
| 99 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8> |
| 100 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST]], splat (i8 15) |
| 101 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[AND]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 102 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 103 | +; CHECK-NEXT: [[SHL:%.*]] = shl nuw <8 x i16> [[BITCAST1]], splat (i16 4) |
| 104 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 105 | +; CHECK-NEXT: [[AND3:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 -16) |
| 106 | +; CHECK-NEXT: ret <16 x i8> [[AND3]] |
| 107 | +; |
| 108 | + %bitcast = bitcast <8 x i16> %arg to <16 x i8> |
| 109 | + %and = and <16 x i8> %bitcast, splat (i8 15) |
| 110 | + %shufflevector = shufflevector <16 x i8> %and, <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 111 | + %bitcast1 = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 112 | + %shl = shl nuw <8 x i16> %bitcast1, splat (i16 4) |
| 113 | + %bitcast2 = bitcast <8 x i16> %shl to <16 x i8> |
| 114 | + %and3 = and <16 x i8> %bitcast2, splat (i8 -16) |
| 115 | + ret <16 x i8> %and3 |
| 116 | +} |
| 117 | + |
| 118 | +define <16 x i8> @knownbits_interleave_mul_extract_bit(<16 x i8> %arg) { |
| 119 | +; CHECK-LABEL: define <16 x i8> @knownbits_interleave_mul_extract_bit( |
| 120 | +; CHECK-SAME: <16 x i8> [[ARG:%.*]]) { |
| 121 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[ARG]], <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23> |
| 122 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 123 | +; CHECK-NEXT: [[MUL:%.*]] = mul nuw <8 x i16> [[BITCAST]], <i16 171, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0> |
| 124 | +; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[MUL]], splat (i16 15) |
| 125 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8> |
| 126 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST1]], splat (i8 1) |
| 127 | +; CHECK-NEXT: ret <16 x i8> [[AND]] |
| 128 | +; |
| 129 | + %shufflevector = shufflevector <16 x i8> %arg, <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison, i8 poison>, <16 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23> |
| 130 | + %bitcast = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 131 | + %mul = mul nuw <8 x i16> %bitcast, <i16 171, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0> |
| 132 | + %lshr = lshr <8 x i16> %mul, splat (i16 15) |
| 133 | + %bitcast1 = bitcast <8 x i16> %lshr to <16 x i8> |
| 134 | + %and = and <16 x i8> %bitcast1, splat (i8 1) |
| 135 | + ret <16 x i8> %and |
| 136 | +} |
| 137 | + |
| 138 | +define <16 x i8> @knownbits_reverse_shuffle_masked_ops(<8 x i16> %arg) { |
| 139 | +; CHECK-LABEL: define <16 x i8> @knownbits_reverse_shuffle_masked_ops( |
| 140 | +; CHECK-SAME: <8 x i16> [[ARG:%.*]]) { |
| 141 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <8 x i16> [[ARG]] to <16 x i8> |
| 142 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 143 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 144 | +; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4) |
| 145 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8> |
| 146 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 3) |
| 147 | +; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4) |
| 148 | +; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 149 | +; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 48) |
| 150 | +; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND]], [[AND4]] |
| 151 | +; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16> |
| 152 | +; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2) |
| 153 | +; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8> |
| 154 | +; CHECK-NEXT: [[AND8:%.*]] = and <16 x i8> [[BITCAST7]], splat (i8 -4) |
| 155 | +; CHECK-NEXT: ret <16 x i8> [[AND8]] |
| 156 | +; |
| 157 | + %bitcast = bitcast <8 x i16> %arg to <16 x i8> |
| 158 | + %shufflevector = shufflevector <16 x i8> %bitcast, <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 159 | + %bitcast1 = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 160 | + %lshr = lshr <8 x i16> %bitcast1, splat (i16 4) |
| 161 | + %bitcast2 = bitcast <8 x i16> %lshr to <16 x i8> |
| 162 | + %and = and <16 x i8> %bitcast2, splat (i8 3) |
| 163 | + %shl = shl <8 x i16> %bitcast1, splat (i16 4) |
| 164 | + %bitcast3 = bitcast <8 x i16> %shl to <16 x i8> |
| 165 | + %and4 = and <16 x i8> %bitcast3, splat (i8 48) |
| 166 | + %or = or disjoint <16 x i8> %and, %and4 |
| 167 | + %bitcast5 = bitcast <16 x i8> %or to <8 x i16> |
| 168 | + %shl6 = shl nuw <8 x i16> %bitcast5, splat (i16 2) |
| 169 | + %bitcast7 = bitcast <8 x i16> %shl6 to <16 x i8> |
| 170 | + %and8 = and <16 x i8> %bitcast7, splat (i8 -4) |
| 171 | + ret <16 x i8> %and8 |
| 172 | +} |
| 173 | + |
| 174 | +define <16 x i8> @knownbits_v4i32_to_v16i8_shuffle_masked_pipeline(<4 x i32> %arg) { |
| 175 | +; CHECK-LABEL: define <16 x i8> @knownbits_v4i32_to_v16i8_shuffle_masked_pipeline( |
| 176 | +; CHECK-SAME: <4 x i32> [[ARG:%.*]]) { |
| 177 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i32> [[ARG]] to <16 x i8> |
| 178 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <16 x i8> [[BITCAST]], <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 179 | +; CHECK-NEXT: [[BITCAST1:%.*]] = bitcast <16 x i8> [[SHUFFLEVECTOR]] to <8 x i16> |
| 180 | +; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST1]], splat (i16 4) |
| 181 | +; CHECK-NEXT: [[BITCAST2:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 182 | +; CHECK-NEXT: [[AND:%.*]] = and <16 x i8> [[BITCAST2]], splat (i8 48) |
| 183 | +; CHECK-NEXT: [[LSHR:%.*]] = lshr <8 x i16> [[BITCAST1]], splat (i16 4) |
| 184 | +; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[LSHR]] to <16 x i8> |
| 185 | +; CHECK-NEXT: [[AND4:%.*]] = and <16 x i8> [[BITCAST3]], splat (i8 3) |
| 186 | +; CHECK-NEXT: [[OR:%.*]] = or disjoint <16 x i8> [[AND4]], [[AND]] |
| 187 | +; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <16 x i8> [[OR]] to <8 x i16> |
| 188 | +; CHECK-NEXT: [[SHL6:%.*]] = shl nuw <8 x i16> [[BITCAST5]], splat (i16 2) |
| 189 | +; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8> |
| 190 | +; CHECK-NEXT: [[AND8:%.*]] = and <16 x i8> [[BITCAST7]], splat (i8 -4) |
| 191 | +; CHECK-NEXT: ret <16 x i8> [[AND8]] |
| 192 | +; |
| 193 | + %bitcast = bitcast <4 x i32> %arg to <16 x i8> |
| 194 | + %shufflevector = shufflevector <16 x i8> %bitcast, <16 x i8> poison, <16 x i32> <i32 3, i32 2, i32 1, i32 0, i32 7, i32 6, i32 5, i32 4, i32 11, i32 10, i32 9, i32 8, i32 15, i32 14, i32 13, i32 12> |
| 195 | + %bitcast1 = bitcast <16 x i8> %shufflevector to <8 x i16> |
| 196 | + %shl = shl <8 x i16> %bitcast1, splat (i16 4) |
| 197 | + %bitcast2 = bitcast <8 x i16> %shl to <16 x i8> |
| 198 | + %and = and <16 x i8> %bitcast2, splat (i8 48) |
| 199 | + %lshr = lshr <8 x i16> %bitcast1, splat (i16 4) |
| 200 | + %bitcast3 = bitcast <8 x i16> %lshr to <16 x i8> |
| 201 | + %and4 = and <16 x i8> %bitcast3, splat (i8 3) |
| 202 | + %or = or disjoint <16 x i8> %and4, %and |
| 203 | + %bitcast5 = bitcast <16 x i8> %or to <8 x i16> |
| 204 | + %shl6 = shl nuw <8 x i16> %bitcast5, splat (i16 2) |
| 205 | + %bitcast7 = bitcast <8 x i16> %shl6 to <16 x i8> |
| 206 | + %and8 = and <16 x i8> %bitcast7, splat (i8 -4) |
| 207 | + ret <16 x i8> %and8 |
| 208 | +} |
| 209 | + |
| 210 | +define { i32, i1 } @knownbits_popcount_add_with_overflow(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3) { |
| 211 | +; CHECK-LABEL: define { i32, i1 } @knownbits_popcount_add_with_overflow( |
| 212 | +; CHECK-SAME: i32 [[ARG:%.*]], i32 [[ARG1:%.*]], i32 [[ARG2:%.*]], i32 [[ARG3:%.*]]) { |
| 213 | +; CHECK-NEXT: [[INSERTELEMENT:%.*]] = insertelement <4 x i32> poison, i32 [[ARG2]], i64 0 |
| 214 | +; CHECK-NEXT: [[INSERTELEMENT4:%.*]] = insertelement <4 x i32> [[INSERTELEMENT]], i32 [[ARG3]], i64 1 |
| 215 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i32> [[INSERTELEMENT4]] to <2 x i64> |
| 216 | +; CHECK-NEXT: [[CALL:%.*]] = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> [[BITCAST]]) |
| 217 | +; CHECK-NEXT: [[BITCAST5:%.*]] = bitcast <2 x i64> [[CALL]] to <4 x i32> |
| 218 | +; CHECK-NEXT: [[EXTRACTELEMENT:%.*]] = extractelement <4 x i32> [[BITCAST5]], i64 0 |
| 219 | +; CHECK-NEXT: [[INSERTELEMENT6:%.*]] = insertelement <4 x i32> poison, i32 [[ARG]], i64 0 |
| 220 | +; CHECK-NEXT: [[INSERTELEMENT7:%.*]] = insertelement <4 x i32> [[INSERTELEMENT6]], i32 [[ARG1]], i64 1 |
| 221 | +; CHECK-NEXT: [[BITCAST8:%.*]] = bitcast <4 x i32> [[INSERTELEMENT7]] to <2 x i64> |
| 222 | +; CHECK-NEXT: [[CALL9:%.*]] = tail call range(i64 0, 65) <2 x i64> @llvm.ctpop.v2i64(<2 x i64> [[BITCAST8]]) |
| 223 | +; CHECK-NEXT: [[BITCAST10:%.*]] = bitcast <2 x i64> [[CALL9]] to <4 x i32> |
| 224 | +; CHECK-NEXT: [[EXTRACTELEMENT11:%.*]] = extractelement <4 x i32> [[BITCAST10]], i64 0 |
| 225 | +; CHECK-NEXT: [[TMP1:%.*]] = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[EXTRACTELEMENT]], i32 [[EXTRACTELEMENT11]]) |
| 226 | +; CHECK-NEXT: ret { i32, i1 } [[TMP1]] |
| 227 | +; |
| 228 | + %insertelement = insertelement <4 x i32> poison, i32 %arg2, i64 0 |
| 229 | + %insertelement4 = insertelement <4 x i32> %insertelement, i32 %arg3, i64 1 |
| 230 | + %bitcast = bitcast <4 x i32> %insertelement4 to <2 x i64> |
| 231 | + %call = tail call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %bitcast) |
| 232 | + %bitcast5 = bitcast <2 x i64> %call to <4 x i32> |
| 233 | + %extractelement = extractelement <4 x i32> %bitcast5, i64 0 |
| 234 | + %insertelement6 = insertelement <4 x i32> poison, i32 %arg, i64 0 |
| 235 | + %insertelement7 = insertelement <4 x i32> %insertelement6, i32 %arg1, i64 1 |
| 236 | + %bitcast8 = bitcast <4 x i32> %insertelement7 to <2 x i64> |
| 237 | + %call9 = tail call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %bitcast8) |
| 238 | + %bitcast10 = bitcast <2 x i64> %call9 to <4 x i32> |
| 239 | + %extractelement11 = extractelement <4 x i32> %bitcast10, i64 0 |
| 240 | + %call12 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %extractelement, i32 %extractelement11) |
| 241 | + ret { i32, i1 } %call12 |
| 242 | +} |
| 243 | + |
| 244 | +define <16 x i8> @knownbits_shuffle_add_shift_v32i8(<32 x i8> %arg, <32 x i8> %arg1) local_unnamed_addr #0 { |
| 245 | +; CHECK-LABEL: define <16 x i8> @knownbits_shuffle_add_shift_v32i8( |
| 246 | +; CHECK-SAME: <32 x i8> [[ARG:%.*]], <32 x i8> [[ARG1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 247 | +; CHECK-NEXT: [[SHUFFLEVECTOR:%.*]] = shufflevector <32 x i8> [[ARG]], <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> |
| 248 | +; CHECK-NEXT: [[SHUFFLEVECTOR2:%.*]] = shufflevector <32 x i8> [[ARG]], <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31> |
| 249 | +; CHECK-NEXT: [[ADD:%.*]] = add <16 x i8> [[SHUFFLEVECTOR]], [[SHUFFLEVECTOR2]] |
| 250 | +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <16 x i8> [[ADD]] to <8 x i16> |
| 251 | +; CHECK-NEXT: [[SHL:%.*]] = shl <8 x i16> [[BITCAST]], splat (i16 8) |
| 252 | +; CHECK-NEXT: [[BITCAST3:%.*]] = bitcast <8 x i16> [[SHL]] to <16 x i8> |
| 253 | +; CHECK-NEXT: [[BITCAST4:%.*]] = bitcast <32 x i8> [[ARG1]] to <16 x i16> |
| 254 | +; CHECK-NEXT: [[SHUFFLEVECTOR5:%.*]] = shufflevector <16 x i16> [[BITCAST4]], <16 x i16> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> |
| 255 | +; CHECK-NEXT: [[SHL6:%.*]] = shl <8 x i16> [[SHUFFLEVECTOR5]], splat (i16 8) |
| 256 | +; CHECK-NEXT: [[BITCAST7:%.*]] = bitcast <8 x i16> [[SHL6]] to <16 x i8> |
| 257 | +; CHECK-NEXT: [[BITCAST8:%.*]] = bitcast <32 x i8> [[ARG1]] to <16 x i16> |
| 258 | +; CHECK-NEXT: [[SHUFFLEVECTOR9:%.*]] = shufflevector <16 x i16> [[BITCAST8]], <16 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 259 | +; CHECK-NEXT: [[SHL10:%.*]] = shl <8 x i16> [[SHUFFLEVECTOR9]], splat (i16 8) |
| 260 | +; CHECK-NEXT: [[BITCAST11:%.*]] = bitcast <8 x i16> [[SHL10]] to <16 x i8> |
| 261 | +; CHECK-NEXT: [[ADD12:%.*]] = add <16 x i8> [[BITCAST11]], [[BITCAST7]] |
| 262 | +; CHECK-NEXT: [[ADD13:%.*]] = add <16 x i8> [[ADD12]], [[BITCAST3]] |
| 263 | +; CHECK-NEXT: [[BITCAST14:%.*]] = bitcast <16 x i8> [[ADD12]] to <8 x i16> |
| 264 | +; CHECK-NEXT: [[SHL15:%.*]] = shl <8 x i16> [[BITCAST14]], splat (i16 8) |
| 265 | +; CHECK-NEXT: [[BITCAST16:%.*]] = bitcast <8 x i16> [[SHL15]] to <16 x i8> |
| 266 | +; CHECK-NEXT: [[ADD17:%.*]] = add <16 x i8> [[ADD13]], [[BITCAST16]] |
| 267 | +; CHECK-NEXT: ret <16 x i8> [[ADD17]] |
| 268 | +; |
| 269 | + %shufflevector = shufflevector <32 x i8> %arg, <32 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> |
| 270 | + %shufflevector2 = shufflevector <32 x i8> %arg, <32 x i8> poison, <16 x i32> <i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31> |
| 271 | + %add = add <16 x i8> %shufflevector, %shufflevector2 |
| 272 | + %bitcast = bitcast <16 x i8> %add to <8 x i16> |
| 273 | + %shl = shl <8 x i16> %bitcast, splat (i16 8) |
| 274 | + %bitcast3 = bitcast <8 x i16> %shl to <16 x i8> |
| 275 | + %bitcast4 = bitcast <32 x i8> %arg1 to <16 x i16> |
| 276 | + %shufflevector5 = shufflevector <16 x i16> %bitcast4, <16 x i16> poison, <8 x i32> <i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> |
| 277 | + %shl6 = shl <8 x i16> %shufflevector5, splat (i16 8) |
| 278 | + %bitcast7 = bitcast <8 x i16> %shl6 to <16 x i8> |
| 279 | + %bitcast8 = bitcast <32 x i8> %arg1 to <16 x i16> |
| 280 | + %shufflevector9 = shufflevector <16 x i16> %bitcast8, <16 x i16> poison, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> |
| 281 | + %shl10 = shl <8 x i16> %shufflevector9, splat (i16 8) |
| 282 | + %bitcast11 = bitcast <8 x i16> %shl10 to <16 x i8> |
| 283 | + %add12 = add <16 x i8> %bitcast11, %bitcast7 |
| 284 | + %add13 = add <16 x i8> %add12, %bitcast3 |
| 285 | + %bitcast14 = bitcast <16 x i8> %add12 to <8 x i16> |
| 286 | + %shl15 = shl <8 x i16> %bitcast14, splat (i16 8) |
| 287 | + %bitcast16 = bitcast <8 x i16> %shl15 to <16 x i8> |
| 288 | + %add17 = add <16 x i8> %add13, %bitcast16 |
| 289 | + ret <16 x i8> %add17 |
| 290 | +} |
| 291 | + |
| 292 | +declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>) #0 |
| 293 | + |
| 294 | +declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) #0 |
| 295 | + |
| 296 | +attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } |
0 commit comments