Skip to content

Commit 09edb1a

Browse files
committed
[SPIRV] Use desugared type when processing binary op
Fixes microsoft#7945
1 parent 85f7653 commit 09edb1a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6875,6 +6875,7 @@ SpirvInstruction *SpirvEmitter::doUnaryOperator(const UnaryOperator *expr) {
68756875
}
68766876

68776877
spv::Op SpirvEmitter::translateOp(BinaryOperator::Opcode op, QualType type) {
6878+
type = type.getDesugaredType(astContext);
68786879
const bool isSintType = isSintOrVecMatOfSintType(type);
68796880
const bool isUintType = isUintOrVecMatOfUintType(type);
68806881
const bool isFloatType = isFloatOrVecMatOfFloatType(type);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %dxc -spirv -T lib_6_8 %s -fcgl | FileCheck %s
2+
3+
enum LuminairePlanesSymmetry : uint
4+
{
5+
ISOTROPIC = 0u,
6+
NO_LATERAL_SYMMET
7+
};
8+
9+
using symmetry_t = LuminairePlanesSymmetry;
10+
const symmetry_t symmetry;
11+
12+
[numthreads(1,1,1)]
13+
[shader("compute")]
14+
void main(uint3 id : SV_DispatchThreadID)
15+
{
16+
// CHECK: [[AC:%[0-9]+]] = OpAccessChain %_ptr_Uniform_int %_Globals %int_0
17+
// CHECK: [[LHS:%[0-9]+]] = OpLoad %int [[AC]]
18+
// CHECK: [[RHS:%[0-9]+]] = OpLoad %int %ISOTROPIC
19+
// CHECK: OpIEqual %bool [[LHS]] [[RHS]]
20+
const uint i0 = (symmetry == symmetry_t::ISOTROPIC) ? 0u : 1u;
21+
}

0 commit comments

Comments
 (0)