Skip to content

Commit 30ee7ba

Browse files
GuillaumeGomezantoyo
authored andcommitted
Add shl and shr missing casts
1 parent 684a69b commit 30ee7ba

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
613613
// user defined names
614614
let mut name = String::with_capacity(prefix.len() + 6);
615615
name.push_str(prefix);
616-
name.push_str(".");
616+
name.push('.');
617617
name.push_str(&(idx as u64).to_base(ALPHANUMERIC_ONLY));
618618
name
619619
}

src/int.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
8383
let b = self.context.new_cast(self.location, b, a_type);
8484
a >> b
8585
} else {
86-
a >> b
86+
let a_size = a_type.get_size();
87+
let b_size = b_type.get_size();
88+
if a_size > b_size {
89+
let b = self.context.new_cast(self.location, b, a_type);
90+
a >> b
91+
} else if a_size < b_size {
92+
let a = self.context.new_cast(self.location, a, b_type);
93+
a >> b
94+
} else {
95+
a >> b
96+
}
8797
}
8898
} else if a_type.is_vector() && a_type.is_vector() {
8999
a >> b
@@ -635,7 +645,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
635645
let b = self.context.new_cast(self.location, b, a_type);
636646
a << b
637647
} else {
638-
a << b
648+
let a_size = a_type.get_size();
649+
let b_size = b_type.get_size();
650+
if a_size > b_size {
651+
let b = self.context.new_cast(self.location, b, a_type);
652+
a << b
653+
} else if a_size < b_size {
654+
let a = self.context.new_cast(self.location, a, b_type);
655+
a << b
656+
} else {
657+
a << b
658+
}
639659
}
640660
} else if a_type.is_vector() && a_type.is_vector() {
641661
a << b

0 commit comments

Comments
 (0)