perf: bitvector literals in match patterns (#3485)

This commit is contained in:
Leonardo de Moura 2024-02-23 16:38:46 -08:00 committed by GitHub
parent 3ead33bd13
commit d179d6c8d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 0 deletions

View file

@ -450,6 +450,7 @@ def canUnfoldAtMatcher (cfg : Config) (info : ConstantInfo) : CoreM Bool := do
|| info.name == ``Char.ofNat || info.name == ``Char.ofNatAux
|| info.name == ``String.decEq || info.name == ``List.hasDecEq
|| info.name == ``Fin.ofNat
|| info.name == ``Fin.ofNat' -- It is used to define `BitVec` literals
|| info.name == ``UInt8.ofNat || info.name == ``UInt8.decEq
|| info.name == ``UInt16.ofNat || info.name == ``UInt16.decEq
|| info.name == ``UInt32.ofNat || info.name == ``UInt32.decEq

View file

@ -0,0 +1,22 @@
open BitVec
def f (x : BitVec 32) : Nat :=
match x with
| 10#32 => 0
| 100#32 => 2
| 200#32 => 3
| 300#32 => 4
| 400#32 => 5
| 500#32 => 6
| 600#32 => 7
| 700#32 => 8
| 800#32 => 9
| 900#32 => 10
| 910#32 => 11
| 920#32 => 12
| _ => 1000
set_option maxHeartbeats 500
example : f 500#32 = x := by
simp [f]
sorry