Fix build-let in cptypes - #961
Conversation
|
This might not be necessary. Unless something has changed, the FASL printer and linker maintain eq-ness of values. So the only danger would be in propagating non-immediate values to separately compiled object files, e.g., through cross-library optimization. In any case, the behavior of |
|
I never use https://github.com/cisco/ChezScheme/blob/main/release_notes/release_notes.stex#L444-L448
I'm not sure how strong is that guaranty. For example that makes a lot of sense knowing the implementation details, but may be surprising. For example, now has no reductions in cptypes but if the and then |
|
I agree with @dybvig that this change doesn't seem necessary. For other places where there's a check currently, do you have in mind |
|
Just to be clear, I'd be happy if the decision is not to merge this. Moreover, I'd send a PR in the oposite direction. For example, let's imagine I delete the guard in Lines 1737 to 1741 in 07b679b Anyway, my reasoning is this: In then is mysterious. I guess But in I expect it to be In then, if I remove the guard, in the final expression both is I guess But in this case is also I guess The difference is the new Anyway, in all the scenarios I consider that |
|
Small fix, just in case. |
When cptypes has to duplicate an expression, it uses
build-let to create temporary variables
But it tries to propagate the obvious cases, like in
(bitwise-and (f) 7)
=>
(let ([t (f)])
(if (fixnum? t)
(fxand t 7)
(bitwise-and t 7)))
where 7 is copied instead of assigned to a temporary
variable.
Don't propagate numbers that are not fixnums to avoid
problems with eq?.
db9e772 to
3134329
Compare
|
I'm closing this, but anyway I squashed the commit in case someone wants to review it in the future. (Fell free to reopen it if you wish.) |
When
cptypeshas to duplicate an expression, it usesbuild-letto create temporary variablesBut it tries to propagate the obvious cases, like in
where
7is copied instead of assigned to a temporary variable.Don't propagate numbers that are not fixnums to avoid problems with
eq?.The main idea is that it's fine to have information moduo
eqv?inside thetypes tree, that is good to reducebut it's important to not copy that info like in
I took a look and I think all the other similar sites are careful to avoid copying non-fixnum-numbers, but the auxiliar function
prepare-letdoes not check this, so I'm adding the check now.I used
prepare-letandbuild-letmostly with special cases for fixnums, so I couldn't find a way to cause a bug, but I think it's better to be more cautions. So, this is a change to make it more safe just in case.