https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91326
Bug ID: 91326
Summary: VRP does not handle array value range
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Created attachment 46659
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46659&action=edit
testcase
For the attached code, gcc "10.0.0 20190730" -O3 generates:
foo:
movsx rdi, edi
mov eax, 1
mov edx, DWORD PTR arr[0+rdi*4]
test edx, edx
je .L1
xor eax, eax
cmp edx, 10
setg al
add eax, eax
.L1:
ret
bar:
xor eax, eax
cmp edi, 2
seta al
ret
baz:
xor eax, eax
ret
clang "7.1.0" and "8.0.1" -O3 generate the optimal code for all 3 versions:
foo:
xor eax, eax
ret
bar:
xor eax, eax
ret
baz:
xor eax, eax
ret