summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-07-27 05:56:27 +0000
committerCraig Topper <craig.topper@intel.com>2018-07-27 05:56:27 +0000
commit561e298e29b17123198396cda679d0e6c1ca021e (patch)
treefe3a2c507f0b9d36ce985e5eb2e9895839ff7ef9 /llvm/test
parenteae4742d81ef598dc2000312ad2471c4632bcb83 (diff)
downloadbcm5719-llvm-561e298e29b17123198396cda679d0e6c1ca021e.tar.gz
bcm5719-llvm-561e298e29b17123198396cda679d0e6c1ca021e.zip
[X86] Remove an unnecessary 'if' that prevented treating INT64_MAX and -INT64_MAX as power of 2 minus 1 in the multiply expansion code.
Not sure why they were being explicitly excluded, but I believe all the math inside the if works. I changed the absolute value to be uint64_t instead of int64_t so INT64_MIN+1 wouldn't be signed wrap. llvm-svn: 338101
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/imul.ll29
1 files changed, 27 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/X86/imul.ll b/llvm/test/CodeGen/X86/imul.ll
index 14f15143b95..0f1a824f00f 100644
--- a/llvm/test/CodeGen/X86/imul.ll
+++ b/llvm/test/CodeGen/X86/imul.ll
@@ -499,8 +499,9 @@ entry:
define i64 @testOverflow(i64 %a) {
; X64-LABEL: testOverflow:
; X64: # %bb.0: # %entry
-; X64-NEXT: movabsq $9223372036854775807, %rax # imm = 0x7FFFFFFFFFFFFFFF
-; X64-NEXT: imulq %rdi, %rax
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: shlq $63, %rax
+; X64-NEXT: subq %rdi, %rax
; X64-NEXT: retq
;
; X86-LABEL: testOverflow:
@@ -524,3 +525,27 @@ entry:
%tmp3 = mul i64 %a, 9223372036854775807
ret i64 %tmp3
}
+
+define i64 @testNegOverflow(i64 %a) {
+; X64-LABEL: testNegOverflow:
+; X64: # %bb.0: # %entry
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: shlq $63, %rax
+; X64-NEXT: subq %rax, %rdi
+; X64-NEXT: movq %rdi, %rax
+; X64-NEXT: retq
+;
+; X86-LABEL: testNegOverflow:
+; X86: # %bb.0: # %entry
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl $1, %edx
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: mull %edx
+; X86-NEXT: shll $31, %ecx
+; X86-NEXT: addl %ecx, %edx
+; X86-NEXT: addl {{[0-9]+}}(%esp), %edx
+; X86-NEXT: retl
+entry:
+ %tmp3 = mul i64 %a, -9223372036854775807
+ ret i64 %tmp3
+}
OpenPOWER on IntegriCloud