Browse Source

Allow int16 types for any/all intrinsics (#1004)

Young Kim 7 years ago
parent
commit
1e07446f9e
2 changed files with 11 additions and 2 deletions
  1. 2 0
      tools/clang/lib/Sema/SemaHLSL.cpp
  2. 9 2
      tools/clang/test/CodeGenHLSL/int16Op.hlsl

+ 2 - 0
tools/clang/lib/Sema/SemaHLSL.cpp

@@ -994,6 +994,8 @@ static const ArBasicKind g_AnyCT[] =
   AR_BASIC_MIN10FLOAT,
   AR_BASIC_MIN16FLOAT,
   AR_BASIC_LITERAL_INT,
+  AR_BASIC_INT16,
+  AR_BASIC_UINT16,
   AR_BASIC_INT32,
   AR_BASIC_UINT32,
   AR_BASIC_MIN12INT,

+ 9 - 2
tools/clang/test/CodeGenHLSL/int16Op.hlsl

@@ -3,12 +3,17 @@
 // CHECK: @dx.op.binary.i16
 // CHECK: @dx.op.unaryBits.i16
 // CHECK: @dx.op.unaryBits.i16
+
+// any, all operation
+// CHECK: icmp ne i16
+// CHECK: icmp ne i16
 // CHECK: sub i16
 
+
 struct SUnaryUintOp {
     uint16_t input1;
-    uint16_t input2;
-    uint16_t output;
+    uint16_t4 input2;
+    uint16_t4 output;
 };
 RWStructuredBuffer<SUnaryUintOp> g_buf;
 [numthreads(8,8,1)]
@@ -17,6 +22,8 @@ void main(uint GI : SV_GroupIndex) {
     int16_t output = min(l.input1,l.input2);
     output += firstbithigh(l.input1);
     output += firstbitlow(l.input1);
+    output += any(l.input1);
+    output += all(l.input2);
     output += l.input1 - l.input2;
     l.output = output;
     g_buf[GI] = l;