| Andrea Di Biagio | ce46b97 | 2014-11-05 13:04:14 +0000 | [diff] [blame] | 1 | ; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+sse4.1 < %s | FileCheck %s | 
|  | 2 | ; | 
|  | 3 | ; Verify that the DAGCombiner is able to fold a vector AND into a blend | 
|  | 4 | ; if one of the operands to the AND is a vector of all constants, and each | 
|  | 5 | ; constant element is either zero or all-ones. | 
|  | 6 |  | 
|  | 7 |  | 
|  | 8 | define <4 x i32> @test1(<4 x i32> %A) { | 
|  | 9 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 0, i32 0> | 
|  | 10 | ret <4 x i32> %1 | 
|  | 11 | } | 
|  | 12 | ; CHECK-LABEL: test1 | 
|  | 13 | ; CHECK: blendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3] | 
|  | 14 | ; CHECK-NEXT: retq | 
|  | 15 |  | 
|  | 16 |  | 
|  | 17 | define <4 x i32> @test2(<4 x i32> %A) { | 
|  | 18 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 0> | 
|  | 19 | ret <4 x i32> %1 | 
|  | 20 | } | 
|  | 21 | ; CHECK-LABEL: test2 | 
|  | 22 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5,6,7] | 
|  | 23 | ; CHECK-NEXT: retq | 
|  | 24 |  | 
|  | 25 |  | 
|  | 26 | define <4 x i32> @test3(<4 x i32> %A) { | 
|  | 27 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 -1, i32 0> | 
|  | 28 | ret <4 x i32> %1 | 
|  | 29 | } | 
|  | 30 | ; CHECK-LABEL: test3 | 
|  | 31 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5],xmm1[6,7] | 
|  | 32 | ; CHECK-NEXT: retq | 
|  | 33 |  | 
|  | 34 |  | 
|  | 35 | define <4 x i32> @test4(<4 x i32> %A) { | 
|  | 36 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 0, i32 -1> | 
|  | 37 | ret <4 x i32> %1 | 
|  | 38 | } | 
|  | 39 | ; CHECK-LABEL: test4 | 
|  | 40 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3,4,5],xmm0[6,7] | 
|  | 41 | ; CHECK-NEXT: retq | 
|  | 42 |  | 
|  | 43 |  | 
|  | 44 | define <4 x i32> @test5(<4 x i32> %A) { | 
|  | 45 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 0> | 
|  | 46 | ret <4 x i32> %1 | 
|  | 47 | } | 
|  | 48 | ; CHECK-LABEL: test5 | 
|  | 49 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7] | 
|  | 50 | ; CHECK-NEXT: retq | 
|  | 51 |  | 
|  | 52 |  | 
|  | 53 | define <4 x i32> @test6(<4 x i32> %A) { | 
|  | 54 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 -1> | 
|  | 55 | ret <4 x i32> %1 | 
|  | 56 | } | 
|  | 57 | ; CHECK-LABEL: test6 | 
|  | 58 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5],xmm0[6,7] | 
|  | 59 | ; CHECK-NEXT: retq | 
|  | 60 |  | 
|  | 61 |  | 
|  | 62 | define <4 x i32> @test7(<4 x i32> %A) { | 
|  | 63 | %1 = and <4 x i32> %A, <i32 0, i32 0, i32 -1, i32 -1> | 
|  | 64 | ret <4 x i32> %1 | 
|  | 65 | } | 
|  | 66 | ; CHECK-LABEL: test7 | 
|  | 67 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1,2,3],xmm0[4,5,6,7] | 
|  | 68 | ; CHECK-NEXT: retq | 
|  | 69 |  | 
|  | 70 |  | 
|  | 71 | define <4 x i32> @test8(<4 x i32> %A) { | 
|  | 72 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 0, i32 -1> | 
|  | 73 | ret <4 x i32> %1 | 
|  | 74 | } | 
|  | 75 | ; CHECK-LABEL: test8 | 
|  | 76 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3,4,5],xmm0[6,7] | 
|  | 77 | ; CHECK-NEXT: retq | 
|  | 78 |  | 
|  | 79 |  | 
|  | 80 | define <4 x i32> @test9(<4 x i32> %A) { | 
|  | 81 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 0, i32 0> | 
|  | 82 | ret <4 x i32> %1 | 
|  | 83 | } | 
|  | 84 | ; CHECK-LABEL: test9 | 
|  | 85 | ; CHECK: movq %xmm0, %xmm0 | 
|  | 86 | ; CHECK-NEXT: retq | 
|  | 87 |  | 
|  | 88 |  | 
|  | 89 | define <4 x i32> @test10(<4 x i32> %A) { | 
|  | 90 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 -1, i32 0> | 
|  | 91 | ret <4 x i32> %1 | 
|  | 92 | } | 
|  | 93 | ; CHECK-LABEL: test10 | 
|  | 94 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3,4,5],xmm1[6,7] | 
|  | 95 | ; CHECK-NEXT: retq | 
|  | 96 |  | 
|  | 97 |  | 
|  | 98 | define <4 x i32> @test11(<4 x i32> %A) { | 
|  | 99 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 -1, i32 -1> | 
|  | 100 | ret <4 x i32> %1 | 
|  | 101 | } | 
|  | 102 | ; CHECK-LABEL: test11 | 
|  | 103 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3,4,5,6,7] | 
|  | 104 | ; CHECK-NEXT: retq | 
|  | 105 |  | 
|  | 106 |  | 
|  | 107 | define <4 x i32> @test12(<4 x i32> %A) { | 
|  | 108 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 -1, i32 0> | 
|  | 109 | ret <4 x i32> %1 | 
|  | 110 | } | 
|  | 111 | ; CHECK-LABEL: test12 | 
|  | 112 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3,4,5],xmm1[6,7] | 
|  | 113 | ; CHECK-NEXT: retq | 
|  | 114 |  | 
|  | 115 |  | 
|  | 116 | define <4 x i32> @test13(<4 x i32> %A) { | 
|  | 117 | %1 = and <4 x i32> %A, <i32 -1, i32 -1, i32 0, i32 -1> | 
|  | 118 | ret <4 x i32> %1 | 
|  | 119 | } | 
|  | 120 | ; CHECK-LABEL: test13 | 
|  | 121 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1,2,3],xmm1[4,5],xmm0[6,7] | 
|  | 122 | ; CHECK-NEXT: retq | 
|  | 123 |  | 
|  | 124 |  | 
|  | 125 | define <4 x i32> @test14(<4 x i32> %A) { | 
|  | 126 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 -1> | 
|  | 127 | ret <4 x i32> %1 | 
|  | 128 | } | 
|  | 129 | ; CHECK-LABEL: test14 | 
|  | 130 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7] | 
|  | 131 | ; CHECK-NEXT: retq | 
|  | 132 |  | 
|  | 133 |  | 
|  | 134 | define <4 x i32> @test15(<4 x i32> %A, <4 x i32> %B) { | 
|  | 135 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 -1> | 
|  | 136 | %2 = and <4 x i32> %B, <i32 0, i32 -1, i32 0, i32 0> | 
|  | 137 | %3 = or <4 x i32> %1, %2 | 
|  | 138 | ret <4 x i32> %3 | 
|  | 139 | } | 
|  | 140 | ; CHECK-LABEL: test15 | 
|  | 141 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5,6,7] | 
|  | 142 | ; CHECK-NEXT: retq | 
|  | 143 |  | 
|  | 144 |  | 
|  | 145 | define <4 x i32> @test16(<4 x i32> %A, <4 x i32> %B) { | 
|  | 146 | %1 = and <4 x i32> %A, <i32 -1, i32 0, i32 -1, i32 0> | 
|  | 147 | %2 = and <4 x i32> %B, <i32 0, i32 -1, i32 0, i32 -1> | 
|  | 148 | %3 = or <4 x i32> %1, %2 | 
|  | 149 | ret <4 x i32> %3 | 
|  | 150 | } | 
|  | 151 | ; CHECK-LABEL: test16 | 
|  | 152 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm0[0,1],xmm1[2,3],xmm0[4,5],xmm1[6,7] | 
|  | 153 | ; CHECK-NEXT: retq | 
|  | 154 |  | 
|  | 155 |  | 
|  | 156 | define <4 x i32> @test17(<4 x i32> %A, <4 x i32> %B) { | 
|  | 157 | %1 = and <4 x i32> %A, <i32 0, i32 -1, i32 0, i32 -1> | 
|  | 158 | %2 = and <4 x i32> %B, <i32 -1, i32 0, i32 -1, i32 0> | 
|  | 159 | %3 = or <4 x i32> %1, %2 | 
|  | 160 | ret <4 x i32> %3 | 
|  | 161 | } | 
|  | 162 | ; CHECK-LABEL: test17 | 
|  | 163 | ; CHECK: pblendw {{.*#+}} xmm0 = xmm1[0,1],xmm0[2,3],xmm1[4,5],xmm0[6,7] | 
|  | 164 | ; CHECK-NEXT: retq |