r244492 - Append options for floating-point commutivity when related diagnostics are produced.

Tyler Nowicki via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 10 14:19:07 PDT 2015


Thanks Aaron!

Fixed in r244506.

Tyler

On Mon, Aug 10, 2015 at 12:58 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Mon, Aug 10, 2015 at 3:56 PM, Tyler Nowicki via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
> > Author: tnowicki
> > Date: Mon Aug 10 14:56:40 2015
> > New Revision: 244492
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=244492&view=rev
> > Log:
> > Append options for floating-point commutivity when related diagnostics
> are produced.
> >
> > With this patch clang appends the command line options that would allow
> vectorization when floating-point commutativity is required. Specifically
> those are enabling fast-math or specifying a loop hint.
> >
> > Added:
> >     cfe/trunk/test/Frontend/optimization-remark-options.c
> > Modified:
> >     cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> >     cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> >
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=244492&r1=244491&r2=244492&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
> > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Mon Aug 10
> 14:56:40 2015
> > @@ -45,6 +45,10 @@ def remark_fe_backend_optimization_remar
> >      InGroup<BackendOptimizationRemarkMissed>;
> >  def remark_fe_backend_optimization_remark_analysis : Remark<"%0">,
> BackendInfo,
> >      InGroup<BackendOptimizationRemarkAnalysis>;
> > +def remark_fe_backend_optimization_remark_analysis_fpcommute :
> Remark<"%0; "
> > +    "allow commutativity by specifying ‘#pragma clang loop
> vectorize(enable)’ "
> > +    "before the loop or by providing the compiler option
> ‘-ffast-math’">,
> > +    BackendInfo, InGroup<BackendOptimizationRemarkAnalysis>;
>
> It looks like some non-ASCII characters snuck in here.
>
> >  def warn_fe_backend_optimization_failure : Warning<"%0">, BackendInfo,
> >      InGroup<BackendOptimizationFailure>, DefaultWarn;
> >  def note_fe_backend_optimization_remark_invalid_loc : Note<"could "
> >
> > Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=244492&r1=244491&r2=244492&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
> > +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Mon Aug 10 14:56:40 2015
> > @@ -256,6 +256,8 @@ namespace clang {
> >          const llvm::DiagnosticInfoOptimizationRemarkMissed &D);
> >      void OptimizationRemarkHandler(
> >          const llvm::DiagnosticInfoOptimizationRemarkAnalysis &D);
> > +    void OptimizationRemarkHandler(
> > +        const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute
> &D);
> >      void OptimizationFailureHandler(
> >          const llvm::DiagnosticInfoOptimizationFailure &D);
> >    };
> > @@ -500,6 +502,17 @@ void BackendConsumer::OptimizationRemark
> >          D, diag::remark_fe_backend_optimization_remark_analysis);
> >  }
> >
> > +void BackendConsumer::OptimizationRemarkHandler(
> > +    const llvm::DiagnosticInfoOptimizationRemarkAnalysisFPCommute &D) {
> > +  // Optimization analysis remarks are active only if the
> -Rpass-analysis
> > +  // flag has a regular expression that matches the name of the pass
> > +  // name in \p D.
> > +  if (CodeGenOpts.OptimizationRemarkAnalysisPattern &&
> > +
> CodeGenOpts.OptimizationRemarkAnalysisPattern->match(D.getPassName()))
> > +    EmitOptimizationMessage(
> > +        D,
> diag::remark_fe_backend_optimization_remark_analysis_fpcommute);
> > +}
> > +
> >  void BackendConsumer::OptimizationFailureHandler(
> >      const llvm::DiagnosticInfoOptimizationFailure &D) {
> >    EmitOptimizationMessage(D,
> diag::warn_fe_backend_optimization_failure);
> > @@ -553,6 +566,12 @@ void BackendConsumer::DiagnosticHandlerI
> >      OptimizationRemarkHandler(
> >          cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI));
> >      return;
> > +  case llvm::DK_OptimizationRemarkAnalysisFPCommute:
> > +    // Optimization remarks are always handled completely by this
> > +    // handler. There is no generic way of emitting them.
> > +    OptimizationRemarkHandler(
> > +        cast<DiagnosticInfoOptimizationRemarkAnalysisFPCommute>(DI));
> > +    return;
> >    case llvm::DK_OptimizationFailure:
> >      // Optimization failures are always handled completely by this
> >      // handler.
> >
> > Added: cfe/trunk/test/Frontend/optimization-remark-options.c
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/optimization-remark-options.c?rev=244492&view=auto
> >
> ==============================================================================
> > --- cfe/trunk/test/Frontend/optimization-remark-options.c (added)
> > +++ cfe/trunk/test/Frontend/optimization-remark-options.c Mon Aug 10
> 14:56:40 2015
> > @@ -0,0 +1,12 @@
> > +// RUN: %clang -O1 -fvectorize -Rpass-analysis=loop-vectorize
> -emit-llvm -S %s -o - 2>&1 | FileCheck %s
> > +
> > +// CHECK: {{.*}}:9:11: remark: loop not vectorized: vectorization
> requires changes in the order of operations, however IEEE 754
> floating-point operations are not commutative; allow commutativity by
> specifying ‘#pragma clang loop vectorize(enable)’ before the loop or by
> providing the compiler option ‘-ffast-math’
>
> Here too.
>
> ~Aaron
>
> > +
> > +double foo(int N) {
> > +  double v = 0.0;
> > +
> > +  for (int i = 0; i < N; i++)
> > +    v = v + 1.0;
> > +
> > +  return v;
> > +}
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150810/c3621ddf/attachment-0001.html>


More information about the cfe-commits mailing list