@@ -83,12 +83,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
8383 let a_size = a_type. get_size ( ) ;
8484 let b_size = b_type. get_size ( ) ;
8585 match a_size. cmp ( & b_size) {
86- std:: cmp:: Ordering :: Less => {
87- let a = self . context . new_cast ( self . location , a, b_type) ;
88- a >> b
89- }
9086 std:: cmp:: Ordering :: Equal => a >> b,
91- std:: cmp:: Ordering :: Greater => {
87+ _ => {
88+ // NOTE: it is OK to cast even if b has a type bigger than a because b has
89+ // been masked by codegen_ssa before calling Builder::lshr or
90+ // Builder::ashr.
9291 let b = self . context . new_cast ( self . location , b, a_type) ;
9392 a >> b
9493 }
@@ -692,12 +691,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
692691 let a_size = a_type. get_size ( ) ;
693692 let b_size = b_type. get_size ( ) ;
694693 match a_size. cmp ( & b_size) {
695- std:: cmp:: Ordering :: Less => {
696- let a = self . context . new_cast ( self . location , a, b_type) ;
697- a << b
698- }
699694 std:: cmp:: Ordering :: Equal => a << b,
700- std:: cmp:: Ordering :: Greater => {
695+ _ => {
696+ // NOTE: it is OK to cast even if b has a type bigger than a because b has
697+ // been masked by codegen_ssa before calling Builder::shl.
701698 let b = self . context . new_cast ( self . location , b, a_type) ;
702699 a << b
703700 }
0 commit comments