diff options
author | Sanjay Patel <spatel@rotateright.com> | 2017-06-22 18:11:19 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2017-06-22 18:11:19 +0000 |
commit | 41a34e411164468818aad59000f41fce9ccbe018 (patch) | |
tree | 8dd2473af7ff53859709d719b54cbdf4e8d102e2 /llvm/unittests/DebugInfo | |
parent | 58ad080ef00adc7bf05605a1bb0c432de51068d4 (diff) | |
download | bcm5719-llvm-41a34e411164468818aad59000f41fce9ccbe018.tar.gz bcm5719-llvm-41a34e411164468818aad59000f41fce9ccbe018.zip |
[x86] add/sub (X==0) --> sbb(neg X)
Our handling of select-of-constants is lumpy in IR (https://reviews.llvm.org/D24480),
lumpy in DAGCombiner, and lumpy in X86ISelLowering. That's why we only had the 'sbb'
codegen in 1 out of the 4 tests. This is a step towards smoothing that out.
First, show that all of these IR forms are equivalent:
http://rise4fun.com/Alive/mx
Second, show that the 'sbb' version is faster/smaller. IACA output for SandyBridge
(later Intel and AMD chips are similar based on Agner's tables):
This is the "obvious" x86 codegen (what gcc appears to produce currently):
| Num Of | Ports pressure in cycles | |
| Uops | 0 - DV | 1 | 2 - D | 3 - D | 4 | 5 | |
---------------------------------------------------------------------
| 1* | | | | | | | | xor eax, eax
| 1 | 1.0 | | | | | | CP | test edi, edi
| 1 | | | | | | 1.0 | CP | setnz al
| 1 | | 1.0 | | | | | CP | neg eax
This is the adc version:
| 1* | | | | | | | | xor eax, eax
| 1 | 1.0 | | | | | | CP | cmp edi, 0x1
| 2 | | 1.0 | | | | 1.0 | CP | adc eax, 0xffffffff
And this is sbb:
| 1 | 1.0 | | | | | | | neg edi
| 2 | | 1.0 | | | | 1.0 | CP | sbb eax, eax
If IACA is trustworthy, then sbb became a single uop in Broadwell, so this will be
clearly better than the alternatives going forward.
llvm-svn: 306040
Diffstat (limited to 'llvm/unittests/DebugInfo')
0 files changed, 0 insertions, 0 deletions