let a_type = a.get_type();
let b_type = b.get_type();
if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type) {
- if a.get_type() != b.get_type() {
- b = self.context.new_cast(None, b, a.get_type());
+ if a_type != b_type {
+ if a_type.is_vector() {
+ // Vector types need to be bitcast.
+ // TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
+ b = self.context.new_bitcast(None, b, a.get_type());
+ }
+ else {
+ b = self.context.new_cast(None, b, a.get_type());
+ }
}
self.context.new_binary_op(None, operation, a_type, a, b)
}
let b_type = b.get_type();
let a_native = self.is_native_int_type_or_bool(a_type);
let b_native = self.is_native_int_type_or_bool(b_type);
- if a_native && b_native {
+ if a_type.is_vector() && b_type.is_vector() {
+ self.context.new_binary_op(None, operation, a_type, a, b)
+ }
+ else if a_native && b_native {
if a_type != b_type {
b = self.context.new_cast(None, b, a_type);
}
else {
// Since u128 and i128 are the only types that can be unsupported, we know the type of
// value and the destination type have the same size, so a bitcast is fine.
+
+ // TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
self.context.new_bitcast(None, value, dest_typ)
}
}