<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120389>120389</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [AVX-512] `movemask(u8) & 1` generates `and al, 1` + `movzx eax, al` instead of `and eax, 1`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Validark
      </td>
    </tr>
</table>

<pre>
    Zig version: ([Godbolt](https://zig.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:zig,selection:(endColumn:1,endLineNumber:8,positionColumn:1,positionLineNumber:8,selectionStartColumn:1,selectionStartLineNumber:8,startColumn:1,startLineNumber:8),source:'export+fn+doo(b:+u8)+u64+%7B%0A++++return+((b+%3E%3E+0)+%26+1)%3B%0A%7D%0A%0Aexport+fn+zoom(args:+@Vector(8,+i64))+u64+%7B%0A++++return+doo(@bitCast(args+%3C+@as(@TypeOf(args),+@splat(0))))%3B%0A%7D%0A'),l:'5',n:'0',o:'Zig+source+%231',t:'0')),k:50,l:'4',m:100,n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:ztrunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:zig,libs:!(),options:'-O+ReleaseFast+-mcpu%3Dznver5+-target+x86_64-linux',overrides:!(),selection:(endColumn:24,endLineNumber:15,positionColumn:24,positionLineNumber:15,selectionStartColumn:24,selectionStartLineNumber:15,startColumn:24,startLineNumber:15),source:1),l:'5',n:'0',o:'+zig+trunk+(Editor+%231)',t:'0')),header:(),k:50,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4))

```zig
export fn doo(b: u8) u64 {
    return ((b >> 0) & 1);
}

export fn zoom(args: @Vector(8, i64)) u64 {
    return doo(@bitCast(args < @as(@TypeOf(args), @splat(0))));
}
```

LLVM version:

```llvm
define dso_local range(i64 0, 2) i64 @doo(i8 zeroext %0) local_unnamed_addr {
Entry:
  %1 = and i8 %0, 1
  %2 = zext nneg i8 %1 to i64
  ret i64 %2
}

define dso_local range(i64 0, 2) i64 @zoom(<8 x i64> %0) local_unnamed_addr {
Entry:
  %1 = icmp slt <8 x i64> %0, zeroinitializer
  %2 = bitcast <8 x i1> %1 to i8
 %3 = and i8 %2, 1
  %4 = zext nneg i8 %3 to i64
  ret i64 %4
}
```

Compiled for znver5:

```diff
doo:
        push    rbp
 mov     rbp, rsp
        mov     eax, edi
        and     eax, 1
 pop     rbp
        ret

zoom:
        push    rbp
        mov rbp, rsp
        vpmovq2m        k0, zmm0
        kmovd   eax, k0
- and     al, 1
-       movzx   eax, al
+       and     eax, 1
        pop rbp
        vzeroupper
        ret
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysV19z664R_TT4hXEGoT-WH_xgK0lfbptOf22mc18ySFop3CBQAfk6_vQdQLKtxE577_wyHsewZ9ndw3KQmDG8lQAblO5Qer9gg31VevPMBK-ZfluUqn7ffOct3oM2XEkUbzGiOUp3f1F1qYRF6T2i-au1vUHxFtFHRB-PvL1rg_lO6dZPxq03R86Z5rcHryjeVqqGh5pbpREtuLfmDRcgWQd-tIoQXSFaNEraPyom3GyUjBP_MvD3Q4CRAPvhzIgWgkkX68hbRAsDAiobSkI0B1kXSgydHLEg629cwt-GrgSN4m2OaNErw53HDDhNfkKfAvxhmbYzn7nps-dnh2u4tTOoQVcjKXDolbaI7hqJ6K5WCtG89KbdEOC7IUsQ3SGartwX2frB-NFgBy3979x7emD8MH7tSFgC0ZRmiO4iP0zjaaF0dT_9Itt5KkelOkRzptvQIzuUkGeo_P7mrmBEd9x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