@@ -240,13 +240,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
240240 if let OperandValueKind :: Immediate ( to_scalar) = cast_kind
241241 && from_scalar. size ( self . cx ) == to_scalar. size ( self . cx )
242242 {
243- let from_backend_ty = bx. backend_type ( operand. layout ) ;
244243 let to_backend_ty = bx. backend_type ( cast) ;
245244 Some ( OperandValue :: Immediate ( self . transmute_immediate (
246245 bx,
247246 imm,
248247 from_scalar,
249- from_backend_ty,
250248 to_scalar,
251249 to_backend_ty,
252250 ) ) )
@@ -262,13 +260,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
262260 && in_a. size ( self . cx ) == out_a. size ( self . cx )
263261 && in_b. size ( self . cx ) == out_b. size ( self . cx )
264262 {
265- let in_a_ibty = bx. scalar_pair_element_backend_type ( operand. layout , 0 , false ) ;
266- let in_b_ibty = bx. scalar_pair_element_backend_type ( operand. layout , 1 , false ) ;
267263 let out_a_ibty = bx. scalar_pair_element_backend_type ( cast, 0 , false ) ;
268264 let out_b_ibty = bx. scalar_pair_element_backend_type ( cast, 1 , false ) ;
269265 Some ( OperandValue :: Pair (
270- self . transmute_immediate ( bx, imm_a, in_a, in_a_ibty , out_a, out_a_ibty) ,
271- self . transmute_immediate ( bx, imm_b, in_b, in_b_ibty , out_b, out_b_ibty) ,
266+ self . transmute_immediate ( bx, imm_a, in_a, out_a, out_a_ibty) ,
267+ self . transmute_immediate ( bx, imm_b, in_b, out_b, out_b_ibty) ,
272268 ) )
273269 } else {
274270 None
@@ -292,12 +288,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
292288 ) -> Option < Bx :: Value > {
293289 use abi:: Primitive :: * ;
294290
295- // When scalars are passed by value, there's no metadata recording their
296- // valid ranges. For example, `char`s are passed as just `i32`, with no
297- // way for LLVM to know that they're 0x10FFFF at most. Thus we assume
298- // the range of the input value too, not just the output range.
299- self . assume_scalar_range ( bx, imm, from_scalar, from_backend_ty) ;
300-
301291 imm = match ( from_scalar. primitive ( ) , to_scalar. primitive ( ) ) {
302292 ( Int ( _, is_signed) , Int ( ..) ) => bx. intcast ( imm, to_backend_ty, is_signed) ,
303293 ( Float ( _) , Float ( _) ) => {
@@ -339,21 +329,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
339329 bx : & mut Bx ,
340330 mut imm : Bx :: Value ,
341331 from_scalar : abi:: Scalar ,
342- from_backend_ty : Bx :: Type ,
343332 to_scalar : abi:: Scalar ,
344333 to_backend_ty : Bx :: Type ,
345334 ) -> Bx :: Value {
335+ use abi:: Primitive :: * ;
336+
346337 assert_eq ! ( from_scalar. size( self . cx) , to_scalar. size( self . cx) ) ;
347338
348- use abi:: Primitive :: * ;
349339 imm = bx. from_immediate ( imm) ;
350340
351- // When scalars are passed by value, there's no metadata recording their
352- // valid ranges. For example, `char`s are passed as just `i32`, with no
353- // way for LLVM to know that they're 0x10FFFF at most. Thus we assume
354- // the range of the input value too, not just the output range.
355- self . assume_scalar_range ( bx, imm, from_scalar, from_backend_ty) ;
356-
357341 imm = match ( from_scalar. primitive ( ) , to_scalar. primitive ( ) ) {
358342 ( Int ( ..) | Float ( _) , Int ( ..) | Float ( _) ) => bx. bitcast ( imm, to_backend_ty) ,
359343 ( Pointer ( ..) , Pointer ( ..) ) => bx. pointercast ( imm, to_backend_ty) ,
@@ -368,55 +352,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
368352 bx. bitcast ( int_imm, to_backend_ty)
369353 }
370354 } ;
371- self . assume_scalar_range ( bx, imm, to_scalar, to_backend_ty) ;
372355 imm = bx. to_immediate_scalar ( imm, to_scalar) ;
373356 imm
374357 }
375358
376- fn assume_scalar_range (
377- & self ,
378- bx : & mut Bx ,
379- imm : Bx :: Value ,
380- scalar : abi:: Scalar ,
381- backend_ty : Bx :: Type ,
382- ) {
383- if matches ! ( self . cx. sess( ) . opts. optimize, OptLevel :: No | OptLevel :: Less )
384- // For now, the critical niches are all over `Int`eger values.
385- // Should floating-point values or pointers ever get more complex
386- // niches, then this code will probably want to handle them too.
387- || !matches ! ( scalar. primitive( ) , abi:: Primitive :: Int ( ..) )
388- || scalar. is_always_valid ( self . cx )
389- {
390- return ;
391- }
392-
393- let abi:: WrappingRange { start, end } = scalar. valid_range ( self . cx ) ;
394-
395- if start <= end {
396- if start > 0 {
397- let low = bx. const_uint_big ( backend_ty, start) ;
398- let cmp = bx. icmp ( IntPredicate :: IntUGE , imm, low) ;
399- bx. assume ( cmp) ;
400- }
401-
402- let type_max = scalar. size ( self . cx ) . unsigned_int_max ( ) ;
403- if end < type_max {
404- let high = bx. const_uint_big ( backend_ty, end) ;
405- let cmp = bx. icmp ( IntPredicate :: IntULE , imm, high) ;
406- bx. assume ( cmp) ;
407- }
408- } else {
409- let low = bx. const_uint_big ( backend_ty, start) ;
410- let cmp_low = bx. icmp ( IntPredicate :: IntUGE , imm, low) ;
411-
412- let high = bx. const_uint_big ( backend_ty, end) ;
413- let cmp_high = bx. icmp ( IntPredicate :: IntULE , imm, high) ;
414-
415- let or = bx. or ( cmp_low, cmp_high) ;
416- bx. assume ( or) ;
417- }
418- }
419-
420359 pub fn codegen_rvalue_unsized (
421360 & mut self ,
422361 bx : & mut Bx ,
0 commit comments