Skip to content

Commit 80d8719

Browse files
authored
use some intrinsics directly in lowering to avoid excessive dependencies on e.g. ! (#24674)
This will help the compiler in the case of packages that add 3VL behavior.
1 parent 1826335 commit 80d8719

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

base/deprecated.jl

-1
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,6 @@ import .Math: clamp
782782
# Deprecate vectorized !
783783
@deprecate(!(A::AbstractArray{Bool}), .!A) # parens for #20541
784784
@deprecate(!(B::BitArray), .!B) # parens for #20541
785-
!(::typeof(()->())) = () # make sure ! has at least 4 methods so that for-loops don't end up getting a back-edge to depwarn
786785

787786
# Deprecate vectorized ~
788787
@deprecate ~(A::AbstractArray) .~A

base/inference.jl

+5
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,11 @@ function abstract_call(@nospecialize(f), fargs::Union{Tuple{},Vector{Any}}, argt
23102310
end
23112311
return Conditional(a, bty, aty)
23122312
end
2313+
elseif f === Core.Inference.not_int
2314+
aty = argtypes[2]
2315+
if isa(aty, Conditional)
2316+
return Conditional(aty.var, aty.elsetype, aty.vtype)
2317+
end
23132318
end
23142319
end
23152320
return isa(rt, TypeVar) ? rt.ub : rt

base/operators.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ julia> "foo" ≠ "foo"
155155
false
156156
```
157157
"""
158-
!=(x, y) = !(x == y)::Bool
158+
!=(x, y) = !(x == y)
159159
const = !=
160160

161161
"""

src/julia-syntax.scm

+6-6
Original file line numberDiff line numberDiff line change
@@ -524,12 +524,12 @@
524524
(for (= ,i (: 1 (call (top >>) (call (top length) ,kw) 1)))
525525
(block
526526
;; ii = i*2 - 1
527-
(= ,ii (call (top -) (call (top *) ,i 2) 1))
527+
(= ,ii (call (top sub_int) (call (top mul_int) ,i 2) 1))
528528
(= ,elt (call (core arrayref) true ,kw ,ii))
529529
,(foldl (lambda (kn else)
530530
(let* ((k (car kn))
531531
(rval0 `(call (core arrayref) true ,kw
532-
(call (top +) ,ii 1)))
532+
(call (top add_int) ,ii 1)))
533533
;; note: if the "declared" type of a KW arg
534534
;; includes something from keyword-sparams
535535
;; then don't assert it here, since those static
@@ -569,7 +569,7 @@
569569
'ccall 2
570570
,rkw (tuple ,elt
571571
(call (core arrayref) true ,kw
572-
(call (top +) ,ii 1)))))
572+
(call (top add_int) ,ii 1)))))
573573
(map (lambda (k temp)
574574
(cons (if (decl? k) `(,(car k) ,temp ,(caddr k)) temp)
575575
(decl-var k)))
@@ -1720,7 +1720,7 @@
17201720
,@(if outer? `((require-existing-local ,lhs)) '())
17211721
,(expand-forms
17221722
`(,while
1723-
(call (top !) (call (top done) ,coll ,state))
1723+
(call (top not_int) (call (core typeassert) (call (top done) ,coll ,state) (core Bool)))
17241724
(block
17251725
;; NOTE: enable this to force loop-local var
17261726
#;,@(map (lambda (v) `(local ,v)) (lhs-vars lhs))
@@ -2548,10 +2548,10 @@
25482548
(inbounds true)
25492549
(call (top setindex!) ,result ,oneresult ,ri)
25502550
(inbounds pop)
2551-
(= ,ri (call (top +) ,ri 1)))
2551+
(= ,ri (call (top add_int) ,ri 1)))
25522552
`(block
25532553
(= ,(car states) (call (top start) ,(car rv)))
2554-
(while (call (top !) (call (top done) ,(car rv) ,(car states)))
2554+
(while (call (top not_int) (call (core typeassert) (call (top done) ,(car rv) ,(car states)) (core Bool)))
25552555
(scope-block
25562556
(block
25572557
(= (tuple ,(cadr (car ranges)) ,(car states))

0 commit comments

Comments
 (0)