-
-
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
inlining: optimize and_int(x, true)
and or_int(x, false)
#54731
base: master
Are you sure you want to change the base?
Conversation
00ef18e
to
6372248
Compare
It is not entirely true, since it actually is equivalent to the type-assert call |
6372248
to
4494e75
Compare
LLVM does not seem to optimize these intrinsic patterns: julia> code_llvm((Bool,)) do x
x & true
end
; Function Signature: var"#10"(Bool)
; @ REPL[1]:2 within `#10`
define i8 @"julia_#10_2272"(i8 zeroext %"x::Bool") #0 {
top:
; ┌ @ bool.jl:38 within `&`
%0 = and i8 %"x::Bool", 1
ret i8 %0
; └
} And I think simplifications for such low-level intrinsics should be done early on? |
4494e75
to
574261f
Compare
That's because LLVM doesn't know that the upper seven bits are ignored... We used to represent bool as i1, but that caused other problems #17225 |
574261f
to
e306bfb
Compare
Clang btw still uses i1 for Bool, so it might be worthwhile trying to switch the implementation back. |
I think our medium term goal is to switch it back. We just have to first make sure that bools on construction always have valid bit-patterns. I believe the plan for how to do this is to always zero initialize bytes that have store bools. |
We need an additional inlining pass to optimize cases like `and_int(x, true)` and `or_int(x, false)` to `x`.
e306bfb
to
1bb8240
Compare
Relevant issue about switching to |
We need an additional inlining pass to optimize cases like
and_int(x, true)
andor_int(x, false)
tox
.