Skip to content

Commit 3d46b93

Browse files
committed
Make sound-/ rules normal rules
1 parent 09bd5d3 commit 3d46b93

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

src/core/egg-herbie.rkt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,6 @@
12481248
['lower
12491249
(define rules (expand-rules (platform-lowering-rules)))
12501250
(egraph-run-rules egg-graph rules #:iter-limit 1 #:scheduler 'simple)]
1251-
['unsound
1252-
(define rules (expand-rules (*sound-removal-rules*)))
1253-
(egraph-run-rules egg-graph rules #:iter-limit 1 #:scheduler 'simple)]
12541251
['rewrite
12551252
(define rules (expand-rules (*rules*)))
12561253
(egraph-run-rules egg-graph rules #:node-limit (*node-limit*))]))
@@ -1292,14 +1289,13 @@
12921289
;; The schedule is a list of step symbols:
12931290
;; - `lift`: run lifting rules for 1 iteration with simple scheduler
12941291
;; - `rewrite`: run rewrite rules up to node limit with backoff scheduler
1295-
;; - `unsound`: run sound-removal rules for 1 iteration with simple scheduler
12961292
;; - `lower`: run lowering rules for 1 iteration with simple scheduler
12971293
(define (make-egraph batch brfs reprs schedule ctx)
12981294
(define (oops! fmt . args)
12991295
(apply error 'verify-schedule! fmt args))
13001296
; verify the schedule
13011297
(for ([step (in-list schedule)])
1302-
(unless (memq step '(lift lower unsound rewrite))
1298+
(unless (memq step '(lift lower rewrite))
13031299
(oops! "unknown schedule step `~a`" step)))
13041300

13051301
(define-values (root-ids egg-graph) (egraph-run-schedule batch brfs schedule ctx))

src/core/egglog-herbie.rkt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,13 @@
6060
;; The schedule is a list of step symbols:
6161
;; - `lift`: run lifting rules for 1 iteration with simple scheduler
6262
;; - `rewrite`: run rewrite rules up to node limit with backoff scheduler
63-
;; - `unsound`: run sound-removal rules for 1 iteration with simple scheduler
6463
;; - `lower`: run lowering rules for 1 iteration with simple scheduler
6564
(define (make-egglog-runner batch brfs reprs schedule ctx)
6665
(define (oops! fmt . args)
6766
(apply error 'verify-schedule! fmt args))
6867
; verify the schedule
6968
(for ([step (in-list schedule)])
70-
(unless (memq step '(lift lower unsound rewrite))
69+
(unless (memq step '(lift lower rewrite))
7170
(oops! "unknown schedule step `~a`" step)))
7271

7372
; make the runner
@@ -147,7 +146,6 @@
147146
(match step
148147
['lift (egglog-send subproc '(run-schedule (saturate lift)))]
149148
['lower (egglog-send subproc '(run-schedule (saturate lower)))]
150-
['unsound (egglog-send subproc '(run-schedule (saturate unsound)))]
151149
;; Run the rewrite ruleset interleaved with const-fold until the best iteration
152150
['rewrite (egglog-unsound-detected-subprocess step subproc)]))
153151

@@ -189,7 +187,6 @@
189187
`(constructor do-lift (MTy) M :unextractable)
190188
`(ruleset lower)
191189
`(ruleset lift)
192-
`(ruleset unsound)
193190
`(function bad-merge? () bool :merge (or old new))
194191
`(ruleset bad-merge-rule)
195192
`(set (bad-merge?) false)
@@ -203,7 +200,6 @@
203200
(num-lowering-rules)
204201
(num-lifting-rules)
205202
(list (approx-lifting-rule))
206-
(egglog-rewrite-rules (*sound-removal-rules*) 'unsound)
207203
(list `(ruleset rewrite))
208204
(egglog-rewrite-rules (*rules*) 'rewrite)))
209205

src/core/patch.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
(timeline-event! 'rewrite)
165165

166166
; egg schedule (4-phases for mathematical rewrites, sound-X removal, and implementation selection)
167-
(define schedule '(lift rewrite unsound lower))
167+
(define schedule '(lift rewrite lower))
168168

169169
(define brfs (map alt-expr altns))
170170
(define reprs (map (batch-reprs global-batch (*context*)) brfs))

src/core/rules.rkt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,9 @@
620620
,(string->symbol (format "t_~a" (unsound-counter))))]
621621
[(list op args ...) (cons op (map add-unsound args))]))
622622

623-
(define (*sound-removal-rules*)
624-
(list (rule 'remove-sound-/ '(/ a b) '(sound-/ a b 0) '(sound-removal))
625-
(rule 'remove-sound-pow '(pow a b) '(sound-pow a b 0) '(sound-removal))
626-
(rule 'remove-sound-log '(log a) '(sound-log a 0) '(sound-removal))))
623+
(define-rules arithmetic
624+
[add-sound-/ '(/ a b) '(sound-/ a b 0)]
625+
[add-sound-pow '(pow a b) '(sound-pow a b 0)]
626+
[add-sound-log '(log a) '(sound-log a 0)]
627+
[remove-sound-/ '(sound-/ a 0 b) b]
628+
[remove-sound-log '(sound-log 0 b) b])

0 commit comments

Comments
 (0)