Hi Richard, On Sun, Nov 22, 2015 at 11:38:31AM +0100, Richard Henderson wrote: > One of which I believe I've worked around in the i386 backend, but I > believe to be a latent problem within combine. > > With the following patch, disable the add<mode>3_*_overflow_2 patterns. > Then compile c-c++-common/torture/builtin-arith-overflow-4.c with -O2 and > you'll see > > t151_2add: > testb %dil, %dil > leal -1(%rdi), %eax > jne .L644 > > which is incorrect. Combine has looked through two comparisons, seen the > NE in the second comparison, and then converted a CCCmode compare to a > CCZmode compare.
It sees the *first* comparison, and its use, and has simplified that. As far as I see, anyway. (It will never look outside a basic block, combine isn't *that* scary!) 0xff + x < 0xff (everything as unsigned char) is the same as x != 0 . Segher