@@ -4601,43 +4601,43 @@ instance IsExprBuilder (ExprBuilder t st fs) where
4601
4601
bvSelect sb idx n x'
4602
4602
4603
4603
-- select is entirely within the less-significant bits of a concat
4604
- | Just (BVConcat _w _a b) <- asApp x
4605
- , Just LeqProof <- testLeq (addNat idx n) (bvWidth b) = do
4606
- bvSelect sb idx n b
4604
+ | Just (BVConcat _w _a b) <- asApp x
4605
+ , Just LeqProof <- testLeq (addNat idx n) (bvWidth b) = do
4606
+ bvSelect sb idx n b
4607
4607
4608
4608
-- select is entirely within the more-significant bits of a concat
4609
- | Just (BVConcat _w a b) <- asApp x
4610
- , Just LeqProof <- testLeq (bvWidth b) idx
4611
- , Just LeqProof <- isPosNat idx
4612
- , let diff = subNat idx (bvWidth b)
4613
- , Just LeqProof <- testLeq (addNat diff n) (bvWidth a) = do
4614
- bvSelect sb (subNat idx (bvWidth b)) n a
4615
-
4616
- -- when the selected region overlaps a concat boundary we have:
4617
- -- select idx n (concat a b) =
4618
- -- concat (select 0 n1 a) (select idx n2 b)
4619
- -- where n1 + n2 = n and idx + n2 = width b
4620
- --
4621
- -- NB: this case must appear after the two above that check for selects
4622
- -- entirely within the first or second arguments of a concat, otherwise
4623
- -- some of the arithmetic checks below may fail
4624
- | Just (BVConcat _w a b) <- asApp x = do
4625
- Just LeqProof <- return $ testLeq idx (bvWidth b)
4626
- let n2 = subNat (bvWidth b) idx
4627
- Just LeqProof <- return $ testLeq n2 n
4628
- let n1 = subNat n n2
4629
- let z = knownNat :: NatRepr 0
4630
-
4631
- Just LeqProof <- return $ isPosNat n1
4632
- Just LeqProof <- return $ testLeq (addNat z n1) (bvWidth a)
4633
- a' <- bvSelect sb z n1 a
4634
-
4635
- Just LeqProof <- return $ isPosNat n2
4636
- Just LeqProof <- return $ testLeq (addNat idx n2) (bvWidth b)
4637
- b' <- bvSelect sb idx n2 b
4638
-
4639
- Just Refl <- return $ testEquality (addNat n1 n2) n
4640
- bvConcat sb a' b'
4609
+ | Just (BVConcat _w a b) <- asApp x
4610
+ , Just LeqProof <- testLeq (bvWidth b) idx
4611
+ , Just LeqProof <- isPosNat idx
4612
+ , let diff = subNat idx (bvWidth b)
4613
+ , Just LeqProof <- testLeq (addNat diff n) (bvWidth a) = do
4614
+ bvSelect sb (subNat idx (bvWidth b)) n a
4615
+
4616
+ -- when the selected region overlaps a concat boundary we have:
4617
+ -- select idx n (concat a b) =
4618
+ -- concat (select 0 n1 a) (select idx n2 b)
4619
+ -- where n1 + n2 = n and idx + n2 = width b
4620
+ --
4621
+ -- NB: this case must appear after the two above that check for selects
4622
+ -- entirely within the first or second arguments of a concat, otherwise
4623
+ -- some of the arithmetic checks below may fail
4624
+ | Just (BVConcat _w a b) <- asApp x = do
4625
+ Just LeqProof <- return $ testLeq idx (bvWidth b)
4626
+ let n2 = subNat (bvWidth b) idx
4627
+ Just LeqProof <- return $ testLeq n2 n
4628
+ let n1 = subNat n n2
4629
+ let z = knownNat :: NatRepr 0
4630
+
4631
+ Just LeqProof <- return $ isPosNat n1
4632
+ Just LeqProof <- return $ testLeq (addNat z n1) (bvWidth a)
4633
+ a' <- bvSelect sb z n1 a
4634
+
4635
+ Just LeqProof <- return $ isPosNat n2
4636
+ Just LeqProof <- return $ testLeq (addNat idx n2) (bvWidth b)
4637
+ b' <- bvSelect sb idx n2 b
4638
+
4639
+ Just Refl <- return $ testEquality (addNat n1 n2) n
4640
+ bvConcat sb a' b'
4641
4641
4642
4642
{- Avoid doing work that may lose sharing...
4643
4643
0 commit comments