diff options
| author | Antoni Boucher <bouanto@zoho.com> | 2022-06-26 14:28:06 -0400 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2022-07-06 15:24:53 -0400 |
| commit | 9db55d2f54e869be328c2f0926786f8fd0ec84a4 (patch) | |
| tree | 5c0fd25303607e20a108c111f15751ead6aa11b3 | |
| parent | 6205f1a0c590381bef30a6faf6bd55ba13d9c05a (diff) | |
| download | rust-9db55d2f54e869be328c2f0926786f8fd0ec84a4.tar.gz rust-9db55d2f54e869be328c2f0926786f8fd0ec84a4.zip | |
Fix vector comparison now returning a vector of integers
| -rw-r--r-- | src/builder.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/builder.rs b/src/builder.rs index 08930387ccb..867fd531f50 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1490,6 +1490,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { let zeros = self.context.new_rvalue_from_vector(None, cond_type, &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 ones = vec![self.context.new_rvalue_one(element_type); num_units]; @@ -1509,6 +1512,16 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> { fn difference_or_zero<'gcc>(a: RValue<'gcc>, b: RValue<'gcc>, context: &'gcc Context<'gcc>) -> RValue<'gcc> { let difference = a - b; 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 } |
