<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 5, 2012, at 10:52 AM, Stephen Hines <<a href="mailto:srhines@google.com">srhines@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Ping for review.</blockquote><div><br></div><div>First, some specific comments on the patch as is, then a larger discussion below.</div><div><br></div><div><div>--- a/lib/Sema/SemaExpr.cpp</div><div>+++ b/lib/Sema/SemaExpr.cpp</div><div>@@ -4662,6 +4662,10 @@ static bool checkCondition(Sema &S, Expr *Cond) {</div><div>   if (S.getLangOpts().OpenCL && CondTy->isVectorType())</div><div>     return false;</div><div> </div><div>+  // VectorSelect extension</div><div>+  if (S.getLangOpts().VectorSelect && CondTy->isVectorType())</div><div>+    return false;</div><div>+</div><div><br></div><div>Since OpenCL implies VectorSelector, the first 'if' statement could be removed.</div><div><br></div><div>In the conditional-checking code, there's support for promoting scalars to vector type for OpenCL, e.g.,</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// OpenCL: If the condition is a vector, and both operands are scalar,</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// attempt to implicity convert them to the vector type to act like the</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(0, 132, 0); "><span style="color: #000000">  </span>// built in select.</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(49, 89, 93); "><span style="color: #000000">  </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (</span>getLangOpts<span style="color: #000000">().</span><span style="color: #4f8187">OpenCL</span><span style="color: #000000"> && CondTy-></span>isVectorType<span style="color: #000000">())</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; color: rgb(49, 89, 93); "><span style="color: #000000">    </span><span style="color: #bb2ca2">if</span><span style="color: #000000"> (</span>checkConditionalConvertScalarsToVectors<span style="color: #000000">(*</span><span style="color: #bb2ca2">this</span><span style="color: #000000">, LHS, RHS, CondTy))</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; ">      <span style="color: #bb2ca2">return</span> <span style="color: #4f8187">QualType</span>();</div><div><br></div><div>I assume that should check VectorSelect rather than OpenCL.</div><div><br></div><div><br></div></div></div><div><div>diff --git a/test/Sema/vector-select.c b/test/Sema/vector-select.c</div><div>new file mode 100644</div><div>index 0000000..9ed8b3f</div><div>--- /dev/null</div><div>+++ b/test/Sema/vector-select.c</div><div>@@ -0,0 +1,130 @@</div><div>+// RUN: %clang_cc1 -fsyntax-only -w -fvector-select -verify %s</div><div>+</div><div>+typedef float  float4 __attribute__((ext_vector_type(4)));</div><div>+typedef double double4 __attribute__((ext_vector_type(4)));</div><div>+typedef signed char   char4 __attribute__((ext_vector_type(4)));</div><div>+typedef short  short4 __attribute__((ext_vector_type(4)));</div><div>+typedef int    int4 __attribute__((ext_vector_type(4)));</div><div>+typedef long   long4 __attribute__((ext_vector_type(4)));</div><div>+typedef long long llong4 __attribute__((ext_vector_type(4)));</div><div>+typedef unsigned char  uchar4 __attribute__((ext_vector_type(4)));</div><div>+typedef unsigned short ushort4 __attribute__((ext_vector_type(4)));</div><div>+typedef unsigned int   uint4  __attribute__((ext_vector_type(4)));</div><div>+typedef unsigned long  ulong4 __attribute__((ext_vector_type(4)));</div><div>+typedef unsigned long long ullong4 __attribute__((ext_vector_type(4)));</div><div>+</div><div>+#define TEST_FUNC_4 test</div><div>+</div><div>+#define DEFINE_TEST_FUNC_4(type) \</div><div>+extern type __attribute__((overloadable)) \</div><div>+TEST_FUNC_4(type a, type b, int selector) { \</div><div>+  type c; \</div><div>+  switch( selector ){ \</div><div>+    case 0: c = a >  b ? a : b; break; \</div><div>+    case 1: c = a >= b ? a : b; break; \</div><div>+    case 2: c = a != b ? a : b; break; \</div><div>+    case 3: c = a == b ? a : b; break; \</div><div>+    case 4: c = a <  b ? a : b; break; \</div><div>+    case 5: c = a <= b ? a : b; break; \</div><div>+    default: \</div><div>+      printf("ERROR: undefined selector\n"); \</div><div>+  } \</div><div>+  return c; \</div><div>+}</div><div>+</div><div>+#define VALIDATE(tester, result) \</div><div>+{ \</div><div>+  if( tester.x != result.x ) failed++; \</div><div>+  if( tester.y != result.y ) failed++; \</div><div>+  if( tester.z != result.z ) failed++; \</div><div>+  if( tester.w != result.w ) failed++; \</div><div>+}</div><div>+</div><div><br></div><div>This test is trying to do two things at once, and should be separated into two tests.</div><div><br></div><div>First, it's checking that semantic analysis accepts this new syntax. The -verify makes sure that no errors occur.</div><div><br></div><div>Second, it's trying to do run-time validation to make sure the generated code is correct (via VALIDATE), but that isn't actually getting exercised: -fsyntax-only prevents IR generation from happening, and the regression tests would not link and run the application anyway. The appropriate way to check for proper IR generation is to put a test in test/CodeGen that uses -emit-llvm and FileCheck to verify that the proper IR is generated.</div><div><br></div><div>Now, back to the patch itself. Rather than adding a new option -fvector-select, I'd rather replace the OpenCL checks with checks for extended vector types (ExtVectorType), since extended vector types are meant to implement OpenCL. Then we don't need another language-dialect-tweaking flag, and anyone using extended vector types, in any of our dialects, gets the same conditional-operator vector selection behavior as in OpenCL.</div><div><br></div></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>- Doug</div><br><blockquote type="cite"><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 31, 2012 at 10:27 AM, Stephen Hines <span dir="ltr"><<a href="mailto:srhines@google.com" target="_blank">srhines@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">Hi Yin (and cfe-commits),<div><br></div><div>I reworked this patch so that it is not dependent on ARM. I added -fvector-select (and the corresponding LangOpts.VectorSelect) to enable this functionality. I also updated the test to work with non-ARM targets. Can CFE-commits take another look and submit if it is acceptable?</div>

<div><br></div><div>Thanks,</div><div>Steve</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 30, 2012 at 1:34 PM, Yin Ma <span dir="ltr"><<a href="mailto:yinma@codeaurora.org" target="_blank">yinma@codeaurora.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><p class="MsoNormal"><span style="color:#1f497d">Hi Stephen,<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">     The attached file are the latest diff file to enable vector select for ARM and <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">A test case that should be placed in test/Sema/ directory. The code has been<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">rebased on the latest clang source. Please give a review. <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">Thanks,<u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d">                            Yin <u></u><u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>

<div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:cfe-commits-bounces@cs.uiuc.edu" target="_blank">cfe-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-commits-bounces@cs.uiuc.edu" target="_blank">cfe-commits-bounces@cs.uiuc.edu</a>] <b>On Behalf Of </b>Yin Ma<br>

<b>Sent:</b> Monday, August 13, 2012 5:55 PM<br><b>To:</b> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br><b>Subject:</b> [cfe-commits] [PATCH][Review place] A Patch to Enable Vector Select for general computing<u></u><u></u></span></p>

</div></div><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Hi,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="text-indent:9.0pt">So far vector select, such as  a < b ? a : c is  not enabled in clang for C/C++ code.<u></u><u></u></p><p class="MsoNormal">It only enabled for OpenCL. I have made a very small change in clang to enable<u></u><u></u></p><p class="MsoNormal">Vector select. I have tested for ARM.  Everything works fine so far. <u></u><u></u></p><p class="MsoNormal">   The file attached enables vector select for general computing. Please give <u></u><u></u></p><p class="MsoNormal">A review.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">

Thanks,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">               Yin <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
_______________________________________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits<br></blockquote></div><br></body></html>