Skip to content

Commit

Permalink
Do not splat %
Browse files Browse the repository at this point in the history
  • Loading branch information
fornwall committed Aug 23, 2023
1 parent 9a44598 commit 016a856
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/front/wgsl/lower/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
left: &mut Handle<crate::Expression>,
right: &mut Handle<crate::Expression>,
) -> Result<(), Error<'source>> {
if matches!(op, crate::BinaryOperator::Modulo) {
if false && matches!(op, crate::BinaryOperator::Modulo) {
self.grow_types(*left)?.grow_types(*right)?;

match (self.resolved_inner(*left), self.resolved_inner(*right)) {
Expand Down
2 changes: 1 addition & 1 deletion src/front/wgsl/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ fn binary_expression_mixed_scalar_and_vector_operands() {
('-', false),
('*', false),
('/', false),
('%', true),
('%', false),
] {
let module = parse_str(&format!(
"
Expand Down
14 changes: 7 additions & 7 deletions tests/out/glsl/operators.main.Compute.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vec4 builtins() {

vec4 splat() {
vec2 a_2 = (((1.0 + vec2(2.0)) - 3.0) / 4.0);
ivec4 b = (ivec4(5) % ivec4(2));
ivec4 b = (ivec4(5) % 2);
return (a_2.xyxy + vec4(b));
}

Expand Down Expand Up @@ -116,12 +116,12 @@ void arithmetic() {
uvec2 div3_1 = (2u / uvec2(1u));
vec2 div4_1 = (vec2(2.0) / 1.0);
vec2 div5_1 = (2.0 / vec2(1.0));
ivec2 rem0_1 = (ivec2(2) % ivec2(1));
ivec2 rem1_1 = (ivec2(2) % ivec2(1));
uvec2 rem2_1 = (uvec2(2u) % uvec2(1u));
uvec2 rem3_1 = (uvec2(2u) % uvec2(1u));
vec2 rem4_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0)));
vec2 rem5_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0)));
ivec2 rem0_1 = (ivec2(2) % 1);
ivec2 rem1_1 = (2 % ivec2(1));
uvec2 rem2_1 = (uvec2(2u) % 1u);
uvec2 rem3_1 = (2u % uvec2(1u));
vec2 rem4_1 = (vec2(2.0) - 1.0 * trunc(vec2(2.0) / 1.0));
vec2 rem5_1 = (2.0 - vec2(1.0) * trunc(2.0 / vec2(1.0)));
}
mat3x3 add = (mat3x3(0.0) + mat3x3(0.0));
mat3x3 sub = (mat3x3(0.0) - mat3x3(0.0));
Expand Down
14 changes: 7 additions & 7 deletions tests/out/hlsl/operators.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ float4 builtins()
float4 splat()
{
float2 a_2 = (((1.0 + (2.0).xx) - 3.0) / 4.0);
int4 b = ((5).xxxx % (2).xxxx);
int4 b = ((5).xxxx % 2);
return (a_2.xyxy + float4(b));
}

Expand Down Expand Up @@ -115,12 +115,12 @@ void arithmetic()
uint2 div3_1 = (2u / (1u).xx);
float2 div4_1 = ((2.0).xx / 1.0);
float2 div5_1 = (2.0 / (1.0).xx);
int2 rem0_1 = ((2).xx % (1).xx);
int2 rem1_1 = ((2).xx % (1).xx);
uint2 rem2_1 = ((2u).xx % (1u).xx);
uint2 rem3_1 = ((2u).xx % (1u).xx);
float2 rem4_1 = fmod((2.0).xx, (1.0).xx);
float2 rem5_1 = fmod((2.0).xx, (1.0).xx);
int2 rem0_1 = ((2).xx % 1);
int2 rem1_1 = (2 % (1).xx);
uint2 rem2_1 = ((2u).xx % 1u);
uint2 rem3_1 = (2u % (1u).xx);
float2 rem4_1 = fmod((2.0).xx, 1.0);
float2 rem5_1 = fmod(2.0, (1.0).xx);
}
float3x3 add = ((float3x3)0 + (float3x3)0);
float3x3 sub = ((float3x3)0 - (float3x3)0);
Expand Down
14 changes: 7 additions & 7 deletions tests/out/msl/operators.msl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ metal::float4 builtins(
metal::float4 splat(
) {
metal::float2 a_2 = ((1.0 + metal::float2(2.0)) - 3.0) / 4.0;
metal::int4 b = metal::int4(5) % metal::int4(2);
metal::int4 b = metal::int4(5) % 2;
return a_2.xyxy + static_cast<metal::float4>(b);
}

Expand Down Expand Up @@ -121,12 +121,12 @@ void arithmetic(
metal::uint2 div3_1 = 2u / metal::uint2(1u);
metal::float2 div4_1 = metal::float2(2.0) / 1.0;
metal::float2 div5_1 = 2.0 / metal::float2(1.0);
metal::int2 rem0_1 = metal::int2(2) % metal::int2(1);
metal::int2 rem1_1 = metal::int2(2) % metal::int2(1);
metal::uint2 rem2_1 = metal::uint2(2u) % metal::uint2(1u);
metal::uint2 rem3_1 = metal::uint2(2u) % metal::uint2(1u);
metal::float2 rem4_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0));
metal::float2 rem5_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0));
metal::int2 rem0_1 = metal::int2(2) % 1;
metal::int2 rem1_1 = 2 % metal::int2(1);
metal::uint2 rem2_1 = metal::uint2(2u) % 1u;
metal::uint2 rem3_1 = 2u % metal::uint2(1u);
metal::float2 rem4_1 = metal::fmod(metal::float2(2.0), 1.0);
metal::float2 rem5_1 = metal::fmod(2.0, metal::float2(1.0));
}
metal::float3x3 add = metal::float3x3 {} + metal::float3x3 {};
metal::float3x3 sub = metal::float3x3 {} - metal::float3x3 {};
Expand Down
30 changes: 15 additions & 15 deletions tests/out/spv/operators.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ OpBranch %60
%67 = OpCompositeConstruct %9 %57 %57
%66 = OpFDiv %9 %64 %67
%68 = OpCompositeConstruct %5 %58 %58 %58 %58
%69 = OpCompositeConstruct %5 %59 %59 %59 %59
%70 = OpSRem %5 %68 %69
%70 = OpCompositeConstruct %5 %59 %59 %59 %59
%69 = OpSRem %5 %68 %70
%71 = OpVectorShuffle %3 %66 %66 0 1 0 1
%72 = OpConvertSToF %3 %70
%72 = OpConvertSToF %3 %69
%73 = OpFAdd %3 %71 %72
OpReturnValue %73
OpFunctionEnd
Expand Down Expand Up @@ -307,23 +307,23 @@ OpBranch %195
%267 = OpCompositeConstruct %9 %55 %55
%266 = OpFDiv %9 %267 %265
%268 = OpCompositeConstruct %129 %59 %59
%269 = OpCompositeConstruct %129 %22 %22
%270 = OpSRem %129 %268 %269
%270 = OpCompositeConstruct %129 %22 %22
%269 = OpSRem %129 %268 %270
%271 = OpCompositeConstruct %129 %22 %22
%272 = OpCompositeConstruct %129 %59 %59
%273 = OpSRem %129 %272 %271
%273 = OpCompositeConstruct %129 %59 %59
%272 = OpSRem %129 %273 %271
%274 = OpCompositeConstruct %203 %123 %123
%275 = OpCompositeConstruct %203 %124 %124
%276 = OpUMod %203 %274 %275
%276 = OpCompositeConstruct %203 %124 %124
%275 = OpUMod %203 %274 %276
%277 = OpCompositeConstruct %203 %124 %124
%278 = OpCompositeConstruct %203 %123 %123
%279 = OpUMod %203 %278 %277
%279 = OpCompositeConstruct %203 %123 %123
%278 = OpUMod %203 %279 %277
%280 = OpCompositeConstruct %9 %55 %55
%281 = OpCompositeConstruct %9 %16 %16
%282 = OpFRem %9 %280 %281
%282 = OpCompositeConstruct %9 %16 %16
%281 = OpFRem %9 %280 %282
%283 = OpCompositeConstruct %9 %16 %16
%284 = OpCompositeConstruct %9 %55 %55
%285 = OpFRem %9 %284 %283
%285 = OpCompositeConstruct %9 %55 %55
%284 = OpFRem %9 %285 %283
OpBranch %196
%196 = OpLabel
%287 = OpCompositeExtract %10 %125 0
Expand Down
14 changes: 7 additions & 7 deletions tests/out/wgsl/operators.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn builtins() -> vec4<f32> {

fn splat() -> vec4<f32> {
let a_2 = (((1.0 + vec2<f32>(2.0)) - 3.0) / 4.0);
let b = (vec4<i32>(5) % vec4<i32>(2));
let b = (vec4<i32>(5) % 2);
return (a_2.xyxy + vec4<f32>(b));
}

Expand Down Expand Up @@ -109,12 +109,12 @@ fn arithmetic() {
let div3_1 = (2u / vec2<u32>(1u));
let div4_1 = (vec2<f32>(2.0) / 1.0);
let div5_1 = (2.0 / vec2<f32>(1.0));
let rem0_1 = (vec2<i32>(2) % vec2<i32>(1));
let rem1_1 = (vec2<i32>(2) % vec2<i32>(1));
let rem2_1 = (vec2<u32>(2u) % vec2<u32>(1u));
let rem3_1 = (vec2<u32>(2u) % vec2<u32>(1u));
let rem4_1 = (vec2<f32>(2.0) % vec2<f32>(1.0));
let rem5_1 = (vec2<f32>(2.0) % vec2<f32>(1.0));
let rem0_1 = (vec2<i32>(2) % 1);
let rem1_1 = (2 % vec2<i32>(1));
let rem2_1 = (vec2<u32>(2u) % 1u);
let rem3_1 = (2u % vec2<u32>(1u));
let rem4_1 = (vec2<f32>(2.0) % 1.0);
let rem5_1 = (2.0 % vec2<f32>(1.0));
}
let add = (mat3x3<f32>() + mat3x3<f32>());
let sub = (mat3x3<f32>() - mat3x3<f32>());
Expand Down

0 comments on commit 016a856

Please sign in to comment.