]> granicus.if.org Git - llvm/commit
[x86] add/sub (X==0) --> sbb(cmp X, 1)
authorSanjay Patel <spatel@rotateright.com>
Thu, 22 Jun 2017 23:47:15 +0000 (23:47 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 22 Jun 2017 23:47:15 +0000 (23:47 +0000)
commitac12e1602f7c7491f34a687f98171b8931f209c9
treefa71e6e66c8f688af105d9e4936fc67fa7372fc5
parentc539eea7c6d10abf894c2e4026a5e734882d5d59
[x86] add/sub (X==0) --> sbb(cmp X, 1)

This is very similar to the transform in:
https://reviews.llvm.org/rL306040
...but in this case, we use cmp X, 1 to set the carry bit as needed.

Again, we can show that all of these are logically equivalent (although
InstCombine currently canonicalizes to a form not seen here), and if
we believe IACA, then this is the smallest/fastest code. Eg, with SNB:

| Num Of |              Ports pressure in cycles               |    |
|  Uops  |  0  - DV  |  1  |  2  -  D  |  3  -  D  |  4  |  5  |    |
---------------------------------------------------------------------
|   1    | 1.0       |     |           |           |     |     |    | cmp edi, 0x1
|   2    |           | 1.0 |           |           |     | 1.0 | CP | sbb eax, eax

The larger motivation is to clean up all select-of-constants combining/lowering
because we're missing some common cases.

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