[PATCH] X86: If we have an instruction that sets a flag and a zero test on the input of that instruction try to eliminate the test.

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Mon May 12 03:10:02 PDT 2014

Hi Benjamin,

your patch looks good to me.
However, I am not the code owner and therefore you might want to have a review from other people as well.

Originally I was a bit concerned because the example you posted in your original message contained an error:

tzcntl	%edi, %ebx
testl %edi, %edi
je	.label

can be rewritten into
tzcntl	%edi, %ebx
jae	.label    <--- this should be 'jb' instead!.

That is because you want to jump to %label only if CF = 1, and not when CF = 0.

..but then I had a look at the code generated and it does the correct thing.
With your patch, your new function @testCTZ2 in test/CodeGen/X86/peep-test-4.ll correctly generates a 'jb'. So it is fine for me.


More information about the llvm-commits mailing list