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

    <tr>
        <th>Summary</th>
        <td>
            Arm count leading sign should be trivial to implement with count leading zero
        </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>
    This code should give me a count-leading-sign operation on arm:

```zig
export fn cls(x: u64) u64 {
    return @clz(if ((x >> 63) == 1) ~x else x);
}
```

At the moment, I get:

```asm
cls:
        eor     x8, x0, x0, asr #63
 clz     x0, x8
        ret
```

[Godbolt link](https://zig.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:3,lang:zig,selection:(endColumn:2,endLineNumber:3,positionColumn:2,positionLineNumber:3,selectionStartColumn:2,selectionStartLineNumber:3,startColumn:2,startLineNumber:3),source:'export+fn+cls(x:+u64)+u64+%7B%0A++++return+@clz(if+((x+%3E%3E+63)+%3D%3D+1)+~x+else+x)%3B%0A%7D'),l:'5',n:'0',o:'Zig+source+%233',t:'0')),header:(),k:75.37473958716589,l:'4',m:33.494883413858304,n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:ztrunk,deviceViewOpen:'1',filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:zig,libs:!(),options:'-O+ReleaseFast+-target+aarch64-linux+-mcpu%3Dapple_latest',overrides:!(),selection:(endColumn:12,endLineNumber:4,positionColumn:12,positionLineNumber:4,selectionStartColumn:12,selectionStartLineNumber:4,startColumn:12,startLineNumber:4),source:3),l:'5',n:'0',o:'+zig+trunk+(Editor+%233)',t:'0')),l:'4',m:66.50511658614172,n:'0',o:'',s:0,t:'0')),k:100.00000000000001,l:'3',n:'0',o:'',t:'0')),version:4)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVk-P46gT_TTkghJh8N9DDnHS_dNPWm2vdnbnsJcVtisO0xgsjDPpHOazrwCnO-5OekcbWdgUr4oCXr3Ah0G0CmCNkhIluwUf7UGb9VcuRcPN86LSzcv6j4MYcK0bwMNBj7LBrTgC7gBzXOtR2aUE3gjVLl0srHsw3AqtsFaYmw6xDSI7RC5tSsJzFm2wwKnXxuK9wrUcEM1PiG3wmMaIFu6FUVYGIMYYG7CjURjFpJZnRHOxx4jmzgsj9oDYA06Zc0Rsh9gOR-77xwmDHACfEC0Qm4KhbPcuoessNxbbA-BOd6Asolv8f9yCvbcUPnTB4hZwweDpB9r49yl3cU7kreWDwYiylE0OtTwHZMDk8zgG7CcJo6T8n24qLS2WQj2jZIdofrC29wnRR0Qfz6JdtQGz0qb1Rtb64Sjs4f3OAbGNY8BDI6w2iG6FH833QoLiHfheFiGaIbrda2W_1Fw6axRPhj8H-O0UYCTAviG2YYhuJVduLscHuh1AQu3YE-KDarZajp3rUkS3oJpfhIJfx64CM_n3ehDOYwa8GD-gXyf4YrmxM5_50EfPjw63cIUb0KOpp00J9Ea03CtEyzeKI1oGkl8-SkSTzDVk4zvTExjvvt8470c864Mbe5iaMg0ZeONuasoo2H44tKsEREtfCzRhl_mSbOdPxWUvQ-JJOCY1OzQden-5wyqnZfrZKGMBYa_xRYh4AN74_fFZO8szYpssWbEszliR5FmUJvnV3HGI5cSDsVVcxHnO4ojlSc5IfC-p0HGEJzfy2N7mdNcLCVeMfrWwzdmaUT0jum3gKGr4KuD7Uw9qznUhLZhQZHk1y6oSipuXGTqYnqpvUNvZQK07pzRPSr7MYjRQje2Wy6Arr_AGOq5aCXOsMI6-RxhmZjhBPdp5hQplQc5QUlSGm5etbuZBrRHdtavbyL3k7XB7N36-8un7ypeiGq6Ox02ke1e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