[Git][cmucl/cmucl][issue-156-take-2-nan-comparison] Add deftransform for >= and <= for integers.
Raymond Toy (@rtoy)
gitlab at common-lisp.net
Sat Mar 11 02:40:41 UTC 2023
Raymond Toy pushed to branch issue-156-take-2-nan-comparison at cmucl / cmucl
Commits:
7ae79da6 by Raymond Toy at 2023-03-10T18:37:11-08:00
Add deftransform for >= and <= for integers.
See the comments in the code for this change. I'm not sure this is
what we want, but the testsuite passes now when it was previously
failing. The failure had something to do with utf-16-be external
format and there were warnings about `(>= foo 0)` having to use
`generic->=` because the first type was `unsigned-byte`. This doesn't
happen anymore.
- - - - -
1 changed file:
- src/compiler/srctran.lisp
Changes:
=====================================
src/compiler/srctran.lisp
=====================================
@@ -3537,6 +3537,29 @@
(deftransform > ((x y) (real real) * :when :both)
(ir1-transform-< y x x y '<))
+
+#+x86
+(progn
+ ;; When x and y are integers, we want to transform <= to > and >= to
+ ;; <. But we don't want to do this for floats because it messes up
+ ;; comparisons with NaN.
+ ;;
+ ;; I'm not sure about this. The transformation is right, but
+ ;; perhaps what we really need is an ir-transform-<= to determine x
+ ;; <= y is definitely true or false, like for ir1-transform-<.
+ ;;
+ ;; For now this allows the testsuite to pass. Perhaps there's a bug
+ ;; in generic->=?
+ (deftransform <= ((x y) (integer integer) * :when :both)
+ ;; (<= x y) is the same as (not (> x y))
+ `(not (> x y)))
+
+
+ (deftransform >= ((x y) (integer integer) * :when :both)
+ ;; (>= x y) is the same as (not (< x y))
+ `(not (< x y))))
+
+
;; Like IR1-TRANSFORM-< but for CHAR<. This is needed so that the
;; vops for base-char comparison with a constant gets used when the
;; first arg is the constant.
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7ae79da601d4a56ba939417fb244244be8c7a431
--
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/7ae79da601d4a56ba939417fb244244be8c7a431
You're receiving this email because of your account on gitlab.common-lisp.net.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cmucl-cvs/attachments/20230311/dde129fa/attachment-0001.html>
More information about the cmucl-cvs
mailing list