Skip to content

Commit d5b329a

Browse files
authored
Reduce estimated cost of not_int to zero (#35707)
This reduces the estimated cost of `not_int` to zero for more reasonable inlining. This change is not a perfect solution, but has little side-effects on the existing cost model.
1 parent 301db97 commit d5b329a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

base/compiler/tfuncs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ add_tfunc(rem_float_fast, 2, 2, math_tfunc, 10)
143143
add_tfunc(and_int, 2, 2, math_tfunc, 1)
144144
add_tfunc(or_int, 2, 2, math_tfunc, 1)
145145
add_tfunc(xor_int, 2, 2, math_tfunc, 1)
146-
add_tfunc(not_int, 1, 1, math_tfunc, 1)
146+
add_tfunc(not_int, 1, 1, math_tfunc, 0) # usually used as not_int(::Bool) to negate a condition
147147
add_tfunc(shl_int, 2, 2, math_tfunc, 1)
148148
add_tfunc(lshr_int, 2, 2, math_tfunc, 1)
149149
add_tfunc(ashr_int, 2, 2, math_tfunc, 1)

doc/src/devdocs/inference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ Each statement gets analyzed for its total cost in a function called
101101
where `f` is your function and `tt` is the Tuple-type of the arguments:
102102

103103
```jldoctest
104-
# A demo on `fill(3.5, (2, 3))
104+
# A demo on `fill(3.5, (2, 3))`
105105
f = fill
106106
tt = Tuple{Float64, Tuple{Int,Int}}
107107
# Create the objects we need to interact with the compiler
@@ -132,7 +132,7 @@ cst = map(cost, ci.code)
132132
0
133133
0
134134
0
135-
1
135+
0
136136
0
137137
0
138138
0

0 commit comments

Comments
 (0)