For x86, canonicalize max
authorEvan Cheng <evan.cheng@apple.com>
Wed, 4 Jan 2012 01:41:39 +0000 (01:41 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 4 Jan 2012 01:41:39 +0000 (01:41 +0000)
commit56f582d664c54bf4567ec37d0bd16b6d4ea6a6eb
tree885c9db256151200548df5cee4b3dfb938079b5a
parent091523c6487fea71571a42f5d74eaf439f133f8c
For x86, canonicalize max
(x > y) ? x : y
=>
(x >= y) ? x : y

So for something like
(x - y) > 0 : (x - y) ? 0
It will be
(x - y) >= 0 : (x - y) ? 0

This makes is possible to test sign-bit and eliminate a comparison against
zero. e.g.
subl   %esi, %edi
testl  %edi, %edi
movl   $0, %eax
cmovgl %edi, %eax
=>
xorl   %eax, %eax
subl   %esi, $edi
cmovsl %eax, %edi

rdar://10633221

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147512 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/jump_sign.ll