diff options
| author | David Green <david.green@arm.com> | 2019-10-18 09:47:48 +0000 |
|---|---|---|
| committer | David Green <david.green@arm.com> | 2019-10-18 09:47:48 +0000 |
| commit | e6f313b3807d23017d188aa7060b8cad09b3d095 (patch) | |
| tree | a5ee51474dbccbb28c4739edcc39dec640610a6d /llvm/test/CodeGen/X86/uadd_sat_plus.ll | |
| parent | 0c7cc383e5b846bc9e9fcc599d3f342333f5c963 (diff) | |
| download | bcm5719-llvm-e6f313b3807d23017d188aa7060b8cad09b3d095.tar.gz bcm5719-llvm-e6f313b3807d23017d188aa7060b8cad09b3d095.zip | |
[Codegen] Alter the default promotion for saturating adds and subs
The default promotion for the add_sat/sub_sat nodes currently does:
ANY_EXTEND iN to iM
SHL by M-N
[US][ADD|SUB]SAT
L/ASHR by M-N
If the promoted add_sat or sub_sat node is not legal, this can produce code
that effectively does a lot of shifting (and requiring large constants to be
materialised) just to use the overflow flag. It is simpler to just do the
saturation manually, using the higher bitwidth addition and a min/max against
the saturating bounds. That is what this patch attempts to do.
Differential Revision: https://reviews.llvm.org/D68926
llvm-svn: 375211
Diffstat (limited to 'llvm/test/CodeGen/X86/uadd_sat_plus.ll')
| -rw-r--r-- | llvm/test/CodeGen/X86/uadd_sat_plus.ll | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/test/CodeGen/X86/uadd_sat_plus.ll b/llvm/test/CodeGen/X86/uadd_sat_plus.ll index 428e2933c46..ac102033717 100644 --- a/llvm/test/CodeGen/X86/uadd_sat_plus.ll +++ b/llvm/test/CodeGen/X86/uadd_sat_plus.ll @@ -108,17 +108,15 @@ define zeroext i8 @func8(i8 zeroext %x, i8 zeroext %y, i8 zeroext %z) nounwind { define zeroext i4 @func4(i4 zeroext %x, i4 zeroext %y, i4 zeroext %z) nounwind { ; X86-LABEL: func4: ; X86: # %bb.0: -; X86-NEXT: movb {{[0-9]+}}(%esp), %cl ; X86-NEXT: movb {{[0-9]+}}(%esp), %al ; X86-NEXT: mulb {{[0-9]+}}(%esp) -; X86-NEXT: shlb $4, %al -; X86-NEXT: shlb $4, %cl -; X86-NEXT: addb %al, %cl -; X86-NEXT: movzbl %cl, %eax -; X86-NEXT: movl $255, %ecx -; X86-NEXT: cmovael %eax, %ecx -; X86-NEXT: shrb $4, %cl -; X86-NEXT: movzbl %cl, %eax +; X86-NEXT: andb $15, %al +; X86-NEXT: addb {{[0-9]+}}(%esp), %al +; X86-NEXT: movzbl %al, %ecx +; X86-NEXT: cmpb $15, %al +; X86-NEXT: movl $15, %eax +; X86-NEXT: cmovbl %ecx, %eax +; X86-NEXT: movzbl %al, %eax ; X86-NEXT: retl ; ; X64-LABEL: func4: @@ -126,13 +124,12 @@ define zeroext i4 @func4(i4 zeroext %x, i4 zeroext %y, i4 zeroext %z) nounwind { ; X64-NEXT: movl %esi, %eax ; X64-NEXT: # kill: def $al killed $al killed $eax ; X64-NEXT: mulb %dl -; X64-NEXT: shlb $4, %al -; X64-NEXT: shlb $4, %dil -; X64-NEXT: addb %al, %dil -; X64-NEXT: movzbl %dil, %eax -; X64-NEXT: movl $255, %ecx -; X64-NEXT: cmovael %eax, %ecx -; X64-NEXT: shrb $4, %cl +; X64-NEXT: andb $15, %al +; X64-NEXT: addb %dil, %al +; X64-NEXT: movzbl %al, %eax +; X64-NEXT: cmpb $15, %al +; X64-NEXT: movl $15, %ecx +; X64-NEXT: cmovbl %eax, %ecx ; X64-NEXT: movzbl %cl, %eax ; X64-NEXT: retq %a = mul i4 %y, %z |

