https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82889
--- Comment #4 from AK <hiraditya at msn dot com> ---
Seems like clang doesn't sign extend.
$ clang -O3 -std=c++14 -g0
```
.text
.intel_syntax noprefix
.file "example.cpp"
.globl lol(int*, int*, unsigned int, unsigned int)
# -- Begin function lol(int*, int*, unsigned int, unsigned int)
.p2align 4, 0x90
.type lol(int*, int*, unsigned int, unsigned int),@function
lol(int*, int*, unsigned int, unsigned int): #
@lol(int*, int*, unsigned int, unsigned int)
.cfi_startproc
# %bb.0:
# kill: def $edx killed $edx def $rdx
and edx, ecx
mov r8d, ecx
mov ecx, 1
jmp .LBB0_1
.p2align 4, 0x90
.LBB0_4: # in Loop: Header=BB0_1 Depth=1
test al, 1
jne .LBB0_5
.LBB0_7: # in Loop: Header=BB0_1 Depth=1
add edx, ecx
and edx, r8d
inc rcx
.LBB0_1: # =>This Inner Loop Header: Depth=1
mov eax, dword ptr [rsi + 4*rdx]
test eax, eax
js .LBB0_4
# %bb.2: # in Loop: Header=BB0_1 Depth=1
cmp dword ptr [rdi + 4*rax], 42
jne .LBB0_7
# %bb.3:
mov eax, 1
ret
.LBB0_5:
xor eax, eax
ret
.Lfunc_end0:
.size lol(int*, int*, unsigned int, unsigned int),
.Lfunc_end0-lol(int*, int*, unsigned int, unsigned int)
.cfi_endproc
# -- End function
.ident "clang version 16.0.0 (https://github.com/llvm/llvm-project.git
5e22ef3198d1686f7978dd150a3eefad4f737bfc)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
$ gcc -O3 -std=c++14 -g0
```
lol(int*, int*, unsigned int, unsigned int):
and edx, ecx
mov r8d, 1
mov ecx, ecx
jmp .L5
.L10:
cmp DWORD PTR [rdi+rax*4], 42
je .L9
.L4:
add rdx, r8
add r8, 1
and rdx, rcx
.L5:
movsx rax, DWORD PTR [rsi+rdx*4] <--------------- sign extend
test eax, eax
jns .L10
test al, 1
je .L4
xor eax, eax
ret
.L9:
mov eax, 1
ret
```