I see that gcc.dg/tree-ssa/ssa-pre-21.c fails for avr. The computation of k + 1L is done as unsigned int (16 bit), but later ++k is performed as unsigned long (32 bit), and thus array[k+1] is not re-used.
Is this to be considered a big in the optimizers for not optimizing this, or in the testsuite for insisting that it should be? FWIW, equivalent behaviour can be seen natively on i686-pc-linux-gnu by replacing "long" with "long long", as shown in the attachment.
/* { dg-do compile } */ /* { dg-options "-O2 -fdump-tree-pre" } */ long long NumSift (long long *array, unsigned long long k) { if (array[k] < array[k + 1LL]) ++k; return array[k]; } /* There should be only two loads left. */ /* { dg-final { scan-tree-dump-times "= \\\*\[^\n;\]*;" 2 "pre" } } */ /* { dg-final { cleanup-tree-dump "pre" } } */