<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67986>67986</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR:vector] [x86-64] No unmasked gather operation in the Vector dialect and clang `-O3` cannot optimize the full true predicate in AVX512
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang,
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
EllisLambda
</td>
</tr>
</table>
<pre>
I created a all true predicate and apply to gather op:
```
%mask = vector.create_mask %c16, %c16 : vector<16x16xi1>
%0 = vector.gather %a[%c0,%c0][%index], %mask, %index : memref<16x16xi32>, vector<16x16xi32>, vector<16x16xi1>, vector<16x16xi32> into vector<16x16xi32>
```
And the MLIR code lower to LLVM IR looks like the following:
```
%67 = call <16 x i32> @llvm.masked.gather.v16i32.v16p0(<16 x ptr> %66, i32 4, <16 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true>, <16 x i32> <i32 120, i32 121, i32 122, i32 123, i32 124, i32 125, i32 126, i32 127, i32 248, i32 249, i32 250, i32 251, i32 252, i32 253, i32 254, i32 255>)
```
Even using the `clang -c -x ir -O3 -march=znver4` to generate the code, the X86 asm still like:
```
194: c5 fc 46 d0 kxnorw %k0,%k0,%k2
198: 62 51 fd 48 6f ee vmovdqa64 %zmm14,%zmm13
19e: 62 32 7d 4a 90 2c b6 vpgatherdd (%rsi,%zmm14,4),%zmm13{%k2}
1a5: c5 fc 46 d0 kxnorw %k0,%k0,%k2
1a9: 62 51 fd 48 6f f7 vmovdqa64 %zmm15,%zmm14
1af: 62 32 7d 4a 90 34 be vpgatherdd (%rsi,%zmm15,4),%zmm14{%k2}
1b6: c5 fc 46 d0 kxnorw %k0,%k0,%k2
1ba: 62 31 fd 48 6f f8 vmovdqa64 %zmm16,%zmm15
1c0: 62 72 7d 42 90 3c 86 vpgatherdd (%rsi,%zmm16,4),%zmm15{%k2}
1c7: 62 a1 fd 48 6f c1 vmovdqa64 %zmm17,%zmm16
1cd: 62 e2 7d 41 90 04 8e vpgatherdd (%rsi,%zmm17,4),%zmm16{%k1}
```
Is there anyway to avoid repeat generate predicate? Even better just avoid the predicate.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVk2P4jgQ_TXmUgL5O8mBAwOD1FLPjjSH1txWjmPA0_lax9B0__qVnZCgAXZb2su2Wsozdr2qVy67rLrO7mtjlkh8QWIzU0d_aNzya1na7llVeaFmeVO8L59AO6O8KUCBKkvw7migdaawWnkDqi5AtW35Dr6BvfIH46BpEVshvEF4hSQe_vshFZXqXgGxDZyM9o1b9Ox_9j9ToYlEdD0gQGw1rENsTeSZyLMliH0d2fA11eAeUaGCKCo0RnTdf8Wm_8nWhTmHUe8kuB1gnIkeK1M5s5s8Mhpc0vVNKA8nyD8ZgK1984DrXtJWdQH-YODb89MP0E1hoGzejAsJf35--QZPP6BsmtcOSvtq4spdU5bNm633j_YBgmCZxOTpsKsxDjjDECHiuCxP1SKkxxRDYhcnIi2j4dNiRNOLTetdtKFCxr2zjAKPSb2QkjjP1pbE8omL_vew38HfE8PWQR6h-KKUUDJBOkE2QT5BMUE5weQCKU8nmI1Q4AmSCdIJsgnyCYooIrtbAl9PpoZjZ-t9LBkksS5VvYe5hvkZrIP5dwbzSjl9QGzzUZ-M40jieMxNbVw4_MEwFGTwGPDPVILqKui8LctYjg8LkGQ8zmVawE4Dl1BgQDh7PdeNewvF9Doc3vFLR9O0N5UUBIFdATwFuQNjACBwnKrmVPylJA80H1VFeM8QIBtJzEjCKCQFcAUZBqohl5Gk7au-KCDUOhWusxNNYOQhtVfEyZc-ymRz8aHErcbx75NiVXZX7C55JFZcR3kh2d0Vyzjk5t_Fihux_I7YXP53sbma4rwWm95VKq9DHBg0HhmSXimNSjWkn9hWeaNU3FGqk9GHuopSk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