<div dir="ltr">Oh, sorry about that! I'll make that change.<div><br></div><div>Tyler</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 10, 2015 at 4:35 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br>
> From: "Tyler Nowicki via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>><br>
> To: <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> Sent: Monday, August 10, 2015 6:05:17 PM<br>
> Subject: r244526 - Append options for vectorization when pointer checking threshold is exceeded.<br>
><br>
> Author: tnowicki<br>
> Date: Mon Aug 10 18:05:16 2015<br>
> New Revision: 244526<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244526&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244526&view=rev</a><br>
> Log:<br>
> Append options for vectorization when pointer checking threshold is<br>
> exceeded.<br>
><br>
> Following one of the appended options will allow the loop to be<br>
> vectorized. We do not include a command line option for modifying<br>
> the pointer checking threshold because there is no clang-level<br>
> interface for this currently.<br>
><br>
> Modified:<br>
>     cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td<br>
>     cfe/trunk/lib/CodeGen/CodeGenAction.cpp<br>
>     cfe/trunk/test/Frontend/optimization-remark-options.c<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=244526&r1=244525&r2=244526&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=244526&r1=244525&r2=244526&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td<br>
> (original)<br>
> +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Aug<br>
> 10 18:05:16 2015<br>
> @@ -49,6 +49,12 @@ def remark_fe_backend_optimization_remar<br>
>      "allow commutativity by specifying '#pragma clang loop<br>
>      vectorize(enable)' "<br>
>      "before the loop or by providing the compiler option<br>
>      '-ffast-math'">,<br>
>      BackendInfo, InGroup<BackendOptimizationRemarkAnalysis>;<br>
> +def remark_fe_backend_optimization_remark_analysis_aliasing :<br>
> Remark<"%0; "<br>
> +    "avoid runtime pointer checking when you know the arrays will<br>
> always be "<br>
> +    "independent by specifying '#pragma clang loop<br>
> vectorize(assume_safety)' "<br>
> +    "before the loop or by specifying 'restrict' on the array<br>
> arguments. "<br>
<br>
Hi Tyler,<br>
<br>
Sorry I missed this earlier, but this needs to say '__restrict__' (or '__restrict') when compiling in C++ mode because 'restrict' is not a valid keyword in C++.<br>
<br>
Thanks again,<br>
Hal<br>
<br>
> +    "Erroneous results will occur if these options are incorrectly<br>
> applied!">,<br>
> +    BackendInfo, InGroup<BackendOptimizationRemarkAnalysis>;<br>
>  def warn_fe_backend_optimization_failure : Warning<"%0">,<br>
>  BackendInfo,<br>
>      InGroup<BackendOptimizationFailure>, DefaultWarn;<br>
>  def note_fe_backend_optimization_remark_invalid_loc : Note<"could "<br>
><br>
> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=244526&r1=244525&r2=244526&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=244526&r1=244525&r2=244526&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)<br>
> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Aug 10 18:05:16 2015<br>
> @@ -258,6 +258,8 @@ namespace clang {<br>
>          const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D);<br>
>      void OptimizationRemarkHandler(<br>
>          const<br>
>          llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute<br>
>          &D);<br>
> +    void OptimizationRemarkHandler(<br>
> +        const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing<br>
> &D);<br>
>      void OptimizationFailureHandler(<br>
>          const llvm::DiagnosticInfoOptimizationFailure &D);<br>
>    };<br>
> @@ -513,6 +515,17 @@ void BackendConsumer::OptimizationRemark<br>
>          D,<br>
>          diag::remark_fe_backend_optimization_remark_analysis_fpcommute);<br>
>  }<br>
><br>
> +void BackendConsumer::OptimizationRemarkHandler(<br>
> +    const llvm::DiagnosticInfoOptimizationRemarkAnalysisAliasing &D)<br>
> {<br>
> +  // Optimization analysis remarks are active only if the<br>
> -Rpass-analysis<br>
> +  // flag has a regular expression that matches the name of the pass<br>
> +  // name in \p D.<br>
> +  if (CodeGenOpts.OptimizationRemarkAnalysisPattern &&<br>
> +<br>
>      CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName()))<br>
> +    EmitOptimizationMessage(<br>
> +        D,<br>
> diag::remark_fe_backend_optimization_remark_analysis_aliasing);<br>
> +}<br>
> +<br>
>  void BackendConsumer::OptimizationFailureHandler(<br>
>      const llvm::DiagnosticInfoOptimizationFailure &D) {<br>
>    EmitOptimizationMessage(D,<br>
>    diag::warn_fe_backend_optimization_failure);<br>
> @@ -572,6 +585,12 @@ void BackendConsumer::DiagnosticHandlerI<br>
>      OptimizationRemarkHandler(<br>
>          cast<DiagnosticInfoOptimizationRemarkAnalysisFPCommute>(DI));<br>
>      return;<br>
> +  case llvm::DK_OptimizationRemarkAnalysisAliasing:<br>
> +    // Optimization remarks are always handled completely by this<br>
> +    // handler. There is no generic way of emitting them.<br>
> +    OptimizationRemarkHandler(<br>
> +        cast<DiagnosticInfoOptimizationRemarkAnalysisAliasing>(DI));<br>
> +    return;<br>
>    case llvm::DK_OptimizationFailure:<br>
>      // Optimization failures are always handled completely by this<br>
>      // handler.<br>
><br>
> Modified: cfe/trunk/test/Frontend/optimization-remark-options.c<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-options.c?rev=244526&r1=244525&r2=244526&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-options.c?rev=244526&r1=244525&r2=244526&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Frontend/optimization-remark-options.c (original)<br>
> +++ cfe/trunk/test/Frontend/optimization-remark-options.c Mon Aug 10<br>
> 18:05:16 2015<br>
> @@ -10,3 +10,12 @@ double foo(int N) {<br>
><br>
>    return v;<br>
>  }<br>
> +<br>
> +// CHECK: {{.*}}:18:13: remark: loop not vectorized: cannot prove<br>
> pointers refer to independent arrays in memory. The loop requires 9<br>
> runtime independence checks to vectorize the loop, but that would<br>
> exceed the limit of 8 checks; avoid runtime pointer checking when<br>
> you know the arrays will always be independent by specifying<br>
> '#pragma clang loop vectorize(assume_safety)' before the loop or by<br>
> specifying 'restrict' on the array arguments. Erroneous results will<br>
> occur if these options are incorrectly applied!<br>
> +<br>
> +void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {<br>
> +  for (int i = 0; i < N; i++) {<br>
> +    dw[i] = A[i] + B[i - 1] + C[i - 2] + D[i - 3];<br>
> +    uw[i] = A[i] + B[i + 1] + C[i + 2] + D[i + 3];<br>
> +  }<br>
> +}<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span></blockquote></div><br></div>