-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Int128 bit shift issue #3596
Comments
A couple of questions for someone with a 32-bit system to test on:
|
I can get you access to my 32bit test VM, remind me about it later. To answer your questions:
|
For some reason this diff makes type inference unhappy: diff --git a/base/int.jl b/base/int.jl
index deed702..3f16c15 100644
--- a/base/int.jl
+++ b/base/int.jl
@@ -135,21 +135,13 @@ mod(x::Int64, y::Int64) = box(Int64,smod_int(unbox(Int64,x),unbox(Int64,y)))
<<(x::Int16, y::Int32) = box(Int16,shl_int(unbox(Int16,x),unbox(Int32,y)))
<<(x::Int32, y::Int32) = box(Int32,shl_int(unbox(Int32,x),unbox(Int32,y)))
<<(x::Int64, y::Int32) = box(Int64,shl_int(unbox(Int64,x),unbox(Int32,y)))
-if Int === Int64
<<(x::Int128, y::Int32) = box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
-else
-<<(x::Int128, y::Int32) = y==0 ? x : box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
-end
<<(x::Uint8, y::Int32) = box(Uint8,shl_int(unbox(Uint8,x),unbox(Int32,y)))
<<(x::Uint16, y::Int32) = box(Uint16,shl_int(unbox(Uint16,x),unbox(Int32,y)))
<<(x::Uint32, y::Int32) = box(Uint32,shl_int(unbox(Int32,x),unbox(Uint32,y)))
<<(x::Uint64, y::Int32) = box(Uint64,shl_int(unbox(Uint64,x),unbox(Int32,y)))
-if Int === Int64
<<(x::Uint128, y::Int32) = box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
-else
-<<(x::Uint128, y::Int32) = y==0 ? x : box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
-end
>>(x::Int8, y::Int32) = box(Int8,ashr_int(unbox(Int8,x),unbox(Int32,y)))
>>(x::Int16, y::Int32) = box(Int16,ashr_int(unbox(Int16,x),unbox(Int32,y)))
@@ -175,6 +167,15 @@ end
>>>(x::Uint64, y::Int32) = box(Uint64,lshr_int(unbox(Uint64,x),unbox(Int32,y)))
>>>(x::Uint128, y::Int32) = box(Uint128,lshr_int(unbox(Uint128,x),unbox(Int32,y)))
+# if Int === Int32
+<<(x::Int128, y::Int32) = y==0 ? x : box(Int128,shl_int(unbox(Int128,x),unbox(Int32,y)))
+<<(x::Uint128, y::Int32) = y==0 ? x : box(Uint128,shl_int(unbox(Uint128,x),unbox(Int32,y)))
+>>(x::Int128, y::Int32) = y==0 ? x : box(Int128,ashr_int(unbox(Int128,x),unbox(Int32,y)))
+>>(x::Uint128, y::Int32) = y==0 ? x : box(Uint128,lshr_int(unbox(Uint128,x),unbox(Int32,y)))
+>>>(x::Int128, y::Int32) = y==0 ? x : box(Int128,lshr_int(unbox(Int128,x),unbox(Int32,y)))
+>>>(x::Uint128, y::Int32) = y==0 ? x : box(Uint128,lshr_int(unbox(Uint128,x),unbox(Int32,y)))
+# end
+
bswap(x::Int8) = x
bswap(x::Uint8) = x
bswap(x::Int16) = box(Int16,bswap_int(unbox(Int16,x))) Inference badness:
cc: @JeffBezanson |
The type inference problem went away after I moved this code later in the file. Chalking it up to boot-strap fragility. |
What's the status here? Sounds like the original issue was resolved? Are we tracking an LLVM issue that we can link to here? |
There's a link in the OP. |
Ah, found it. http://llvm.org/bugs/show_bug.cgi?id=16439 |
Well, somebody knew about this at least: llvm-mirror/llvm@36236b7 |
Upstream patch is at http://reviews.llvm.org/D4978 with discussion about how best to lower the 128 bit shift. I challenge anyone to come up with a better instruction sequence :). |
This was committed upstream. |
only a problem on 32 bit (actually has had a workaround in place for some time that should now probably be removed) add a test for repr(::Int128)
only a problem on 32 bit (actually has had a workaround in place for some time that should now probably be removed) add a test for repr(::Int128)
From #3447
is broken.
Corresponding LLVM IR:
LLVM bug no: http://llvm.org/bugs/show_bug.cgi?id=16439
The text was updated successfully, but these errors were encountered: