@@ -83,12 +83,11 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
83
83
let a_size = a_type. get_size ( ) ;
84
84
let b_size = b_type. get_size ( ) ;
85
85
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
- }
90
86
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.
92
91
let b = self . context . new_cast ( self . location , b, a_type) ;
93
92
a >> b
94
93
}
@@ -692,12 +691,10 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
692
691
let a_size = a_type. get_size ( ) ;
693
692
let b_size = b_type. get_size ( ) ;
694
693
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
- }
699
694
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.
701
698
let b = self . context . new_cast ( self . location , b, a_type) ;
702
699
a << b
703
700
}
0 commit comments