diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2016-12-05 15:58:21 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2016-12-05 15:58:21 +0000 |
| commit | 1f158d6955a31b4decf03c5bf2d568f5e29cc2e8 (patch) | |
| tree | ed20ceafce3222143305f6c5b0556c6bbcde28a0 /llvm/test/CodeGen | |
| parent | f807f6a05fbaa06a2a37cf01dc1df7dc357648e9 (diff) | |
| download | bcm5719-llvm-1f158d6955a31b4decf03c5bf2d568f5e29cc2e8.tar.gz bcm5719-llvm-1f158d6955a31b4decf03c5bf2d568f5e29cc2e8.zip | |
[TargetLowering] add special-case for demanded bits analysis of 'not'
We treat bitwise 'not' as a special operation and try not to reduce its all-ones mask.
Presumably, this is because a 'not' may be cheaper than a generic 'xor' or it may get
folded into another logic op if the target has those. However, if we can remove a logic
instruction by changing the xor's constant mask value, that should always be a win.
Note that the IR version of SimplifyDemandedBits() does not treat 'not' as a special-case
currently (although that's marked with a FIXME). So if you run this IR through -instcombine,
you should get the same end result. I'm hoping to add a different backend transform that
will expose this problem though, so I need to solve this first.
Differential Revision: https://reviews.llvm.org/D27356
llvm-svn: 288676
Diffstat (limited to 'llvm/test/CodeGen')
| -rw-r--r-- | llvm/test/CodeGen/X86/not-and-simplify.ll | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/llvm/test/CodeGen/X86/not-and-simplify.ll b/llvm/test/CodeGen/X86/not-and-simplify.ll index 3bee4472c14..dfce6c68150 100644 --- a/llvm/test/CodeGen/X86/not-and-simplify.ll +++ b/llvm/test/CodeGen/X86/not-and-simplify.ll @@ -5,20 +5,12 @@ ; Clear high bits via shift, set them with xor (not), then mask them off. define i32 @shrink_xor_constant1(i32 %x) { -; NO_BMI-LABEL: shrink_xor_constant1: -; NO_BMI: # BB#0: -; NO_BMI-NEXT: shrl $31, %edi -; NO_BMI-NEXT: notl %edi -; NO_BMI-NEXT: andl $1, %edi -; NO_BMI-NEXT: movl %edi, %eax -; NO_BMI-NEXT: retq -; -; BMI-LABEL: shrink_xor_constant1: -; BMI: # BB#0: -; BMI-NEXT: shrl $31, %edi -; BMI-NEXT: movl $1, %eax -; BMI-NEXT: andnl %eax, %edi, %eax -; BMI-NEXT: retq +; ALL-LABEL: shrink_xor_constant1: +; ALL: # BB#0: +; ALL-NEXT: shrl $31, %edi +; ALL-NEXT: xorl $1, %edi +; ALL-NEXT: movl %edi, %eax +; ALL-NEXT: retq ; %sh = lshr i32 %x, 31 %not = xor i32 %sh, -1 @@ -32,8 +24,7 @@ define i8 @shrink_xor_constant2(i8 %x) { ; ALL-LABEL: shrink_xor_constant2: ; ALL: # BB#0: ; ALL-NEXT: shlb $5, %dil -; ALL-NEXT: notb %dil -; ALL-NEXT: andb $-32, %dil +; ALL-NEXT: xorb $-32, %dil ; ALL-NEXT: movl %edi, %eax ; ALL-NEXT: retq ; |

