Is it always safe to make this change without considering the surrounding code? If you start with this code:
testl %ebx, %ebx # Set zero flag if %ebx is zero
movl $0, %eax # Set %eax to zero
jz somewhere # Jump if %ebx was zero
then after optimization you get this: testl %ebx, %ebx # Set zero flag if %ebx is zero
xorl %eax, %eax # Set %eax to zero *and set zero flag*
jz somewhere # Jump always
Maybe this is OK because TCC doesn't (currently) generate any code like this.