scanon added inline comments.

================
Comment at: clang/docs/LanguageExtensions.rst:3182
+enabled for the translation unit with the ``-fassociative-math`` flag.
+The pragma can take two values: ``on`` and ``off``.
+
----------------
mibintc wrote:
> scanon wrote:
> > rjmccall wrote:
> > > Do you want to add an example here?
> > Is the intention that this allows reassociation only within statements 
> > (like fp contract on)? Based on the ir in the tests, I think the answer is 
> > "no".
> > 
> > If so, should "on" be called "fast" instead, since its semantics match the 
> > "fast" semantics for contract, and reserve "on" for reassociation within a 
> > statement (that seems like it would also be useful, potentially)?
> > 
> > Otherwise, please add some tests with multiple statements.
> > 
> > I agree with John that `pragma clang fp reassociate` is a reasonable 
> > spelling.
> The intention is that the pragma can be placed at either file scope or at the 
> start of a compound statement, if at file scope it affects the functions 
> following the pragma.  If at compound statement it is effective for the 
> compound statement, i can modify the test to have multiple statements.  I 
> disagree with the suggestion of "fast" instead of on/off.  at the command 
> line you can use -f[no-]associative-math; of course that command line option 
> isn't specific to floating point, but the point is it's on/off ; i can't 
> speak to whether "fast" would be a useful setting.  Thanks for your review
I don't think you understood my comment, so I'll try to explain more clearly: I 
am not asking if it applies to multiple statements or a single statement; I am 
asking within what scope reassociation is allowed.

An example: `fp contract on` allows:
```
double r = a*b + c;
```
to be contracted to an fma, but does not allow:
```
double t = a*b;
double r = t + c;
```
to be contracted. `fp contract fast` allows both to be contracted.

Your reassociate pragma, if I am understanding correctly, allows:
```
double t = a + b;
double r = t + c;
```
to be reassociated; this matches the behavior of `fp contract fast`. I am 
asking if, for the sake of understandability and orthogonality of the 
floating-point model, it would make more sense for this option to be named 
`fast`, reserving `on` for a mode that only allows reassociation within 
expressions.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78827/new/

https://reviews.llvm.org/D78827



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to