https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89506
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Using the expressions valgrind uses for ARM to compute flags from ADDS and SUBS instructions and a program that simulates it on just 8-bit values instead of 32-bit ones, it seems the only problematic values where the flags change are 0 and INT_MIN. By swapping the alternatives, I think the desirable one (subs) should trigger for both, so the above patch should be hopefully correct. Will bootstrap/regtest it.