(no commit message)
authorlkcl <lkcl@web>
Tue, 3 Aug 2021 09:08:27 +0000 (10:08 +0100)
committerIkiWiki <ikiwiki.info>
Tue, 3 Aug 2021 09:08:27 +0000 (10:08 +0100)
openpower/sv/branches.mdwn

index dfa2ecda01e0492312cdf3b4bbbbb0310dc956a1..3541d389a41d302e850b709ba151371fa01f81b9 100644 (file)
@@ -209,3 +209,43 @@ Pseudocode for Vertical-First Mode:
             SVSTATE.VL = new_srcstep
     SVSTATE.srcstep = new_srcstep
 ```
+
+# Example Shader code
+
+```
+while(a > 2) {
+    if(b < 5)
+        f();
+    else
+        g();
+    h();
+}
+```
+
+which compiles to something like:
+
+```
+vec<i32> a, b;
+// ...
+pred loop_pred = a > 2;
+while(loop_pred.any()) {
+    pred if_pred = loop_pred & (b < 5);
+    if(if_pred.any()) {
+        f(if_pred);
+    }
+label1:
+    pred else_pred = loop_pred & ~if_pred;
+    if(else_pred.any()) {
+        g(else_pred);
+    }
+    h(loop_pred);
+}
+```
+
+which will end up as:
+
+```
+   sv.cmpi CR0, a, 2
+   sv.crweird r30, CR0.GT # transfer GT vector to r30
+while_loop:
+```