Fix vector comparison now returning a vector of integers
This commit is contained in:
parent
6205f1a0c5
commit
9db55d2f54
@ -1490,6 +1490,9 @@ pub fn vector_select(&mut self, cond: RValue<'gcc>, then_val: RValue<'gcc>, else
|
|||||||
let zeros = self.context.new_rvalue_from_vector(None, cond_type, &zeros);
|
let zeros = self.context.new_rvalue_from_vector(None, cond_type, &zeros);
|
||||||
|
|
||||||
let masks = self.context.new_comparison(None, ComparisonOp::NotEquals, cond, zeros);
|
let masks = self.context.new_comparison(None, ComparisonOp::NotEquals, cond, zeros);
|
||||||
|
// NOTE: masks is a vector of integers, but the values can be vectors of floats, so use bitcast to make
|
||||||
|
// the & operation work.
|
||||||
|
let masks = self.bitcast_if_needed(masks, then_val.get_type());
|
||||||
let then_vals = masks & then_val;
|
let then_vals = masks & then_val;
|
||||||
|
|
||||||
let ones = vec![self.context.new_rvalue_one(element_type); num_units];
|
let ones = vec![self.context.new_rvalue_one(element_type); num_units];
|
||||||
@ -1509,6 +1512,16 @@ pub fn vector_select(&mut self, cond: RValue<'gcc>, then_val: RValue<'gcc>, else
|
|||||||
fn difference_or_zero<'gcc>(a: RValue<'gcc>, b: RValue<'gcc>, context: &'gcc Context<'gcc>) -> RValue<'gcc> {
|
fn difference_or_zero<'gcc>(a: RValue<'gcc>, b: RValue<'gcc>, context: &'gcc Context<'gcc>) -> RValue<'gcc> {
|
||||||
let difference = a - b;
|
let difference = a - b;
|
||||||
let masks = context.new_comparison(None, ComparisonOp::GreaterThanEquals, b, a);
|
let masks = context.new_comparison(None, ComparisonOp::GreaterThanEquals, b, a);
|
||||||
|
// NOTE: masks is a vector of integers, but the values can be vectors of floats, so use bitcast to make
|
||||||
|
// the & operation work.
|
||||||
|
let a_type = a.get_type();
|
||||||
|
let masks =
|
||||||
|
if masks.get_type() != a_type {
|
||||||
|
context.new_bitcast(None, masks, a_type)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
masks
|
||||||
|
};
|
||||||
difference & masks
|
difference & masks
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user