@@ -3623,22 +3623,22 @@ void bounds_test() {
36233623 scope.pop (" x" );
36243624
36253625 // Check some bitwise ops.
3626- check (scope, (cast<uint8_t >(x) & cast< uint8_t >( 7 )), u8 (0 ), u8 (7 ));
3627- check (scope, (cast< uint8_t >( 3 ) & cast< uint8_t >( 2 )), u8 (2 ), u8 (2 ));
3628- check (scope, (cast< uint8_t >( 1 ) | cast< uint8_t >( 2 )), u8 (3 ), u8 (3 ));
3629- check (scope, (cast< uint8_t >( 3 ) ^ cast< uint8_t >( 2 )), u8 (1 ), u8 (1 ));
3630- check (scope, (~cast< uint8_t >( 3 )), u8 (0xfc ), u8 (0xfc ));
3626+ check (scope, (cast<uint8_t >(x) & make_const ( UInt ( 8 ), 7 )), u8 (0 ), u8 (7 ));
3627+ check (scope, (make_const ( UInt ( 8 ), 3 ) & make_const ( UInt ( 8 ), 2 )), u8 (2 ), u8 (2 ));
3628+ check (scope, (make_one ( UInt ( 8 )) | make_const ( UInt ( 8 ), 2 )), u8 (3 ), u8 (3 ));
3629+ check (scope, (make_const ( UInt ( 8 ), 3 ) ^ make_const ( UInt ( 8 ), 2 )), u8 (1 ), u8 (1 ));
3630+ check (scope, (~make_const (UInt( 8 ), 3 )), u8 (0xfc ), u8 (0xfc ));
36313631 check (scope, cast<uint8_t >(x + 5 ) & cast<uint8_t >(x + 3 ), u8 (0 ), u8 (13 ));
36323632 check (scope, cast<int8_t >(x - 5 ) & cast<int8_t >(x + 3 ), i8 (0 ), i8 (13 ));
36333633 check (scope, cast<int8_t >(2 * x - 5 ) & cast<int8_t >(x - 3 ), i8 (-128 ), i8 (15 ));
36343634 check (scope, cast<uint8_t >(x + 5 ) | cast<uint8_t >(x + 3 ), u8 (5 ), u8 (255 ));
36353635 check (scope, cast<int8_t >(x + 5 ) | cast<int8_t >(x + 3 ), i8 (3 ), i8 (127 ));
36363636 check (scope, ~cast<uint8_t >(x), u8 (-11 ), u8 (-1 ));
3637- check (scope, (cast<uint8_t >(x) >> cast< uint8_t >( 1 )), u8 (0 ), u8 (5 ));
3638- check (scope, (cast< uint8_t >( 10 ) >> cast< uint8_t >( 1 )), u8 (5 ), u8 (5 ));
3639- check (scope, (cast<uint8_t >(x + 3 ) << cast< uint8_t >( 1 )), u8 (6 ), u8 (26 ));
3640- check (scope, (cast<uint8_t >(x + 3 ) << cast< uint8_t >( 7 )), u8 (0 ), u8 (255 )); // Overflows
3641- check (scope, (cast< uint8_t >( 5 ) << cast< uint8_t >( 1 )), u8 (10 ), u8 (10 ));
3637+ check (scope, (cast<uint8_t >(x) >> make_one ( UInt ( 8 ) )), u8 (0 ), u8 (5 ));
3638+ check (scope, (make_const ( UInt ( 8 ), 10 ) >> make_one ( UInt ( 8 ) )), u8 (5 ), u8 (5 ));
3639+ check (scope, (cast<uint8_t >(x + 3 ) << make_one ( UInt ( 8 ) )), u8 (6 ), u8 (26 ));
3640+ check (scope, (cast<uint8_t >(x + 3 ) << make_const ( UInt ( 8 ), 7 )), u8 (0 ), u8 (255 )); // Overflows
3641+ check (scope, (make_const ( UInt ( 8 ), 5 ) << make_one ( UInt ( 8 ) )), u8 (10 ), u8 (10 ));
36423642 check (scope, (x << 12 ), 0 , 10 << 12 );
36433643 check (scope, x & 4095 , 0 , 10 ); // LHS known to be positive
36443644 check (scope, x & 123 , 0 , 10 ); // Doesn't have to be a precise bitmask
@@ -3712,27 +3712,27 @@ void bounds_test() {
37123712 u16 (0 ), u16 (4095 ));
37133713
37143714 check (scope,
3715- cast<uint8_t >(clamp (cast<uint16_t >(x ^ y), cast< uint16_t >( 0 ), cast< uint16_t >( 128 ))),
3715+ cast<uint8_t >(clamp (cast<uint16_t >(x ^ y), make_zero ( UInt ( 16 )), make_const ( UInt ( 16 ), 128 ))),
37163716 u8 (0 ), u8 (128 ));
37173717
37183718 Expr u8_1 = cast<uint8_t >(Load::make (Int (8 ), " buf" , x, Buffer<>(), Parameter (), const_true (), ModulusRemainder ()));
37193719 Expr u8_2 = cast<uint8_t >(Load::make (Int (8 ), " buf" , x + 17 , Buffer<>(), Parameter (), const_true (), ModulusRemainder ()));
37203720 check (scope, cast<uint16_t >(u8_1) + cast<uint16_t >(u8_2),
37213721 u16 (0 ), u16 (255 * 2 ));
37223722
3723- check (scope, saturating_cast<uint8_t >(clamp (x, 5 , 10 )), cast< uint8_t >( 5 ), cast< uint8_t >( 10 ));
3723+ check (scope, saturating_cast<uint8_t >(clamp (x, 5 , 10 )), make_const ( UInt ( 8 ), 5 ), make_const ( UInt ( 8 ), 10 ));
37243724 {
37253725 scope.push (" x" , Interval (UInt (32 ).min (), UInt (32 ).max ()));
3726- check (scope, saturating_cast<int32_t >(max (cast<uint32_t >(x), cast< uint32_t >( 5 ))), cast< int32_t >( 5 ), Int (32 ).max ());
3726+ check (scope, saturating_cast<int32_t >(max (cast<uint32_t >(x), make_const ( UInt ( 32 ), 5 ))), make_const ( Int ( 32 ), 5 ), Int (32 ).max ());
37273727 scope.pop (" x" );
37283728 }
37293729 {
37303730 Expr z = Variable::make (Float (32 ), " z" );
3731- scope.push (" z" , Interval (cast< float >( -1 ), cast< float >( 1 )));
3732- check (scope, saturating_cast<int32_t >(z), cast< int32_t >( -1 ), cast< int32_t >( 1 ));
3733- check (scope, saturating_cast<double >(z), cast< double >( -1 ), cast< double >( 1 ));
3734- check (scope, saturating_cast<float16_t >(z), cast< float16_t >( -1 ), cast< float16_t >( 1 ));
3735- check (scope, saturating_cast<uint8_t >(z), cast< uint8_t >( 0 ), cast< uint8_t >( 1 ));
3731+ scope.push (" z" , Interval (make_const ( Float ( 32 ), -1 ), make_one ( Float ( 32 ) )));
3732+ check (scope, saturating_cast<int32_t >(z), make_const ( Int ( 32 ), -1 ), make_one ( Int ( 32 ) ));
3733+ check (scope, saturating_cast<double >(z), make_const ( Float ( 64 ), -1 ), make_one ( Float ( 64 ) ));
3734+ check (scope, saturating_cast<float16_t >(z), make_const ( Float ( 16 ), -1 ), make_one ( Float ( 16 ) ));
3735+ check (scope, saturating_cast<uint8_t >(z), make_zero ( UInt ( 8 )), make_one ( UInt ( 8 ) ));
37363736 scope.pop (" z" );
37373737 }
37383738 {
0 commit comments