@@ -282,32 +282,34 @@ impl FunctionBuilder {
282
282
) -> ValueId {
283
283
let base = self . field_constant ( FieldElement :: from ( 2_u128 ) ) ;
284
284
let typ = self . current_function . dfg . type_of_value ( lhs) ;
285
- let ( max_bit, pow) = if let Some ( rhs_constant) =
286
- self . current_function . dfg . get_numeric_constant ( rhs)
287
- {
288
- // Happy case is that we know precisely by how many bits the the integer will
289
- // increase: lhs_bit_size + rhs
290
- let ( rhs_bit_size_pow_2, overflows) =
291
- 2_u32 . overflowing_pow ( rhs_constant. to_u128 ( ) as u32 ) ;
292
- if overflows {
293
- let zero = self . numeric_constant ( FieldElement :: zero ( ) , typ) ;
294
- return InsertInstructionResult :: SimplifiedTo ( zero) . first ( ) ;
295
- }
296
- let pow = self . numeric_constant ( FieldElement :: from ( rhs_bit_size_pow_2 as u128 ) , typ) ;
297
- ( bit_size + ( rhs_constant. to_u128 ( ) as u32 ) , pow)
298
- } else {
299
- // we use a predicate to nullify the result in case of overflow
300
- let bit_size_var =
301
- self . numeric_constant ( FieldElement :: from ( bit_size as u128 ) , typ. clone ( ) ) ;
302
- let overflow = self . insert_binary ( rhs, BinaryOp :: Lt , bit_size_var) ;
303
- let one = self . numeric_constant ( FieldElement :: one ( ) , Type :: unsigned ( 1 ) ) ;
304
- let predicate = self . insert_binary ( overflow, BinaryOp :: Eq , one) ;
305
- let predicate = self . insert_cast ( predicate, typ. clone ( ) ) ;
306
-
307
- let pow = self . pow ( base, rhs) ;
308
- let pow = self . insert_cast ( pow, typ) ;
309
- ( FieldElement :: max_num_bits ( ) , self . insert_binary ( predicate, BinaryOp :: Mul , pow) )
310
- } ;
285
+ let ( max_bit, pow) =
286
+ if let Some ( rhs_constant) = self . current_function . dfg . get_numeric_constant ( rhs) {
287
+ // Happy case is that we know precisely by how many bits the the integer will
288
+ // increase: lhs_bit_size + rhs
289
+ let ( rhs_bit_size_pow_2, overflows) =
290
+ 2_u128 . overflowing_pow ( rhs_constant. to_u128 ( ) as u32 ) ;
291
+ if overflows {
292
+ assert ! ( bit_size < 128 , "ICE - shift left with big integers are not supported" ) ;
293
+ if bit_size < 128 {
294
+ let zero = self . numeric_constant ( FieldElement :: zero ( ) , typ) ;
295
+ return InsertInstructionResult :: SimplifiedTo ( zero) . first ( ) ;
296
+ }
297
+ }
298
+ let pow = self . numeric_constant ( FieldElement :: from ( rhs_bit_size_pow_2) , typ) ;
299
+ ( bit_size + ( rhs_constant. to_u128 ( ) as u32 ) , pow)
300
+ } else {
301
+ // we use a predicate to nullify the result in case of overflow
302
+ let bit_size_var =
303
+ self . numeric_constant ( FieldElement :: from ( bit_size as u128 ) , typ. clone ( ) ) ;
304
+ let overflow = self . insert_binary ( rhs, BinaryOp :: Lt , bit_size_var) ;
305
+ let one = self . numeric_constant ( FieldElement :: one ( ) , Type :: unsigned ( 1 ) ) ;
306
+ let predicate = self . insert_binary ( overflow, BinaryOp :: Eq , one) ;
307
+ let predicate = self . insert_cast ( predicate, typ. clone ( ) ) ;
308
+
309
+ let pow = self . pow ( base, rhs) ;
310
+ let pow = self . insert_cast ( pow, typ) ;
311
+ ( FieldElement :: max_num_bits ( ) , self . insert_binary ( predicate, BinaryOp :: Mul , pow) )
312
+ } ;
311
313
312
314
let instruction = Instruction :: Binary ( Binary { lhs, rhs : pow, operator : BinaryOp :: Mul } ) ;
313
315
if max_bit <= bit_size {
0 commit comments