Eliminate redundant compare between set{z,nz} and j{z,nz}: setz %al; test %al,%al; jz <...> -> setz %al; jnz <...> and setnz %al, test %al,%al; jz <...> -> setnz %al; jz <...>. We can use the original Zero-flag value instead of setting the temporary register and testing it for zero. gcc/ChangeLog: * config/i386/i386.md (redundant compare peephole2): New peephole2 pattern. Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}. Also tested by building and booting the linux kernel (where the peephole2 triggers several times). I was not able to craft the testcase, the original sequence is very elusive and requires reuse of the value, set from the flags elsewhere in the function in a very specific way. Uros.