James Y Knight | 7c90506 | 2015-11-23 21:33:58 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 2 | ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 < %s | FileCheck %s |
Simon Pilgrim | 2415144 | 2016-09-07 13:40:03 +0000 | [diff] [blame^] | 3 | |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 4 | ; |
| 5 | ; Verify that the DAGCombiner is able to fold a vector AND into a blend |
| 6 | ; if one of the operands to the AND is a vector of all constants, and each |
| 7 | ; constant element is either zero or all-ones. |
Simon Pilgrim | 2415144 | 2016-09-07 13:40:03 +0000 | [diff] [blame^] | 8 | ; |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 9 | |
| 10 | define <4 x i32> @test1(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 11 | ; CHECK-LABEL: test1: |
| 12 | ; CHECK: # BB#0: |
| 13 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 14 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3,4,5,6,7] |
| 15 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 16 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 0, i32 0> |
| 17 | ret <4 x i32> %1 |
| 18 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 19 | |
| 20 | define <4 x i32> @test2(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 21 | ; CHECK-LABEL: test2: |
| 22 | ; CHECK: # BB#0: |
| 23 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 24 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5,6,7] |
| 25 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 26 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 0> |
| 27 | ret <4 x i32> %1 |
| 28 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 29 | |
| 30 | define <4 x i32> @test3(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 31 | ; CHECK-LABEL: test3: |
| 32 | ; CHECK: # BB#0: |
| 33 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 34 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5],xmm1[6,7] |
| 35 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 36 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 -1, i32 0> |
| 37 | ret <4 x i32> %1 |
| 38 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 39 | |
| 40 | define <4 x i32> @test4(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 41 | ; CHECK-LABEL: test4: |
| 42 | ; CHECK: # BB#0: |
| 43 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 44 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3,4,5],xmm0[6,7] |
| 45 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 46 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 0, i32 -1> |
| 47 | ret <4 x i32> %1 |
| 48 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 49 | |
| 50 | define <4 x i32> @test5(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 51 | ; CHECK-LABEL: test5: |
| 52 | ; CHECK: # BB#0: |
| 53 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 54 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7] |
| 55 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 56 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 0> |
| 57 | ret <4 x i32> %1 |
| 58 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 59 | |
| 60 | define <4 x i32> @test6(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 61 | ; CHECK-LABEL: test6: |
| 62 | ; CHECK: # BB#0: |
| 63 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 64 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5],xmm0[6,7] |
| 65 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 66 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 -1> |
| 67 | ret <4 x i32> %1 |
| 68 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 69 | |
| 70 | define <4 x i32> @test7(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 71 | ; CHECK-LABEL: test7: |
| 72 | ; CHECK: # BB#0: |
| 73 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 74 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5,6,7] |
| 75 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 76 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 -1, i32 -1> |
| 77 | ret <4 x i32> %1 |
| 78 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 79 | |
| 80 | define <4 x i32> @test8(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 81 | ; CHECK-LABEL: test8: |
| 82 | ; CHECK: # BB#0: |
| 83 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 84 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3,4,5],xmm0[6,7] |
| 85 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 86 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 0, i32 -1> |
| 87 | ret <4 x i32> %1 |
| 88 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 89 | |
| 90 | define <4 x i32> @test9(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 91 | ; CHECK-LABEL: test9: |
| 92 | ; CHECK: # BB#0: |
| 93 | ; CHECK-NEXT: movq {{.*#+}} xmm0 = xmm0[0],zero |
| 94 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 95 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 0, i32 0> |
| 96 | ret <4 x i32> %1 |
| 97 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 98 | |
| 99 | define <4 x i32> @test10(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 100 | ; CHECK-LABEL: test10: |
| 101 | ; CHECK: # BB#0: |
| 102 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 103 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3,4,5],xmm1[6,7] |
| 104 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 105 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 -1, i32 0> |
| 106 | ret <4 x i32> %1 |
| 107 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 108 | |
| 109 | define <4 x i32> @test11(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 110 | ; CHECK-LABEL: test11: |
| 111 | ; CHECK: # BB#0: |
| 112 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 113 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3,4,5,6,7] |
| 114 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 115 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 -1, i32 -1> |
| 116 | ret <4 x i32> %1 |
| 117 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 118 | |
| 119 | define <4 x i32> @test12(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 120 | ; CHECK-LABEL: test12: |
| 121 | ; CHECK: # BB#0: |
| 122 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 123 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7] |
| 124 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 125 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 -1, i32 0> |
| 126 | ret <4 x i32> %1 |
| 127 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 128 | |
| 129 | define <4 x i32> @test13(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 130 | ; CHECK-LABEL: test13: |
| 131 | ; CHECK: # BB#0: |
| 132 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 133 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[4,5],xmm0[6,7] |
| 134 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 135 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 0, i32 -1> |
| 136 | ret <4 x i32> %1 |
| 137 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 138 | |
| 139 | define <4 x i32> @test14(<4 x i32> %A) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 140 | ; CHECK-LABEL: test14: |
| 141 | ; CHECK: # BB#0: |
| 142 | ; CHECK-NEXT: pxor %xmm1, %xmm1 |
| 143 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7] |
| 144 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 145 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 -1> |
| 146 | ret <4 x i32> %1 |
| 147 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 148 | |
| 149 | define <4 x i32> @test15(<4 x i32> %A, <4 x i32> %B) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 150 | ; CHECK-LABEL: test15: |
| 151 | ; CHECK: # BB#0: |
| 152 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7] |
| 153 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 154 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 -1> |
| 155 | %2 = and <4 x i32> %B, <i32 0, i32 -1, i32 0, i32 0> |
| 156 | %3 = or <4 x i32> %1, %2 |
| 157 | ret <4 x i32> %3 |
| 158 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 159 | |
| 160 | define <4 x i32> @test16(<4 x i32> %A, <4 x i32> %B) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 161 | ; CHECK-LABEL: test16: |
| 162 | ; CHECK: # BB#0: |
| 163 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7] |
| 164 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 165 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 0> |
| 166 | %2 = and <4 x i32> %B, <i32 0, i32 -1, i32 0, i32 -1> |
| 167 | %3 = or <4 x i32> %1, %2 |
| 168 | ret <4 x i32> %3 |
| 169 | } |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 170 | |
| 171 | define <4 x i32> @test17(<4 x i32> %A, <4 x i32> %B) { |
Chandler Carruth | 52332dc | 2015-02-04 00:58:37 +0000 | [diff] [blame] | 172 | ; CHECK-LABEL: test17: |
| 173 | ; CHECK: # BB#0: |
| 174 | ; CHECK-NEXT: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5],xmm0[6,7] |
| 175 | ; CHECK-NEXT: retq |
Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 176 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 -1> |
| 177 | %2 = and <4 x i32> %B, <i32 -1, i32 0, i32 -1, i32 0> |
| 178 | %3 = or <4 x i32> %1, %2 |
| 179 | ret <4 x i32> %3 |
| 180 | } |
Simon Pilgrim | 2415144 | 2016-09-07 13:40:03 +0000 | [diff] [blame^] | 181 | |
| 182 | ; |
| 183 | ; fold (and (or x, C), D) -> D if (C & D) == D |
| 184 | ; |
| 185 | |
| 186 | define <2 x i64> @and_or_v2i64(<2 x i64> %a0) { |
| 187 | ; CHECK-LABEL: and_or_v2i64: |
| 188 | ; CHECK: # BB#0: |
| 189 | ; CHECK-NEXT: orps {{.*}}(%rip), %xmm0 |
| 190 | ; CHECK-NEXT: andps {{.*}}(%rip), %xmm0 |
| 191 | ; CHECK-NEXT: retq |
| 192 | %1 = or <2 x i64> %a0, <i64 255, i64 255> |
| 193 | %2 = and <2 x i64> %1, <i64 8, i64 8> |
| 194 | ret <2 x i64> %2 |
| 195 | } |
| 196 | |
| 197 | define <4 x i32> @and_or_v4i32(<4 x i32> %a0) { |
| 198 | ; CHECK-LABEL: and_or_v4i32: |
| 199 | ; CHECK: # BB#0: |
| 200 | ; CHECK-NEXT: orps {{.*}}(%rip), %xmm0 |
| 201 | ; CHECK-NEXT: andps {{.*}}(%rip), %xmm0 |
| 202 | ; CHECK-NEXT: retq |
| 203 | %1 = or <4 x i32> %a0, <i32 15, i32 15, i32 15, i32 15> |
| 204 | %2 = and <4 x i32> %1, <i32 3, i32 3, i32 3, i32 3> |
| 205 | ret <4 x i32> %2 |
| 206 | } |