[PATCH] D113107: Support of expression granularity for _Float16.

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 17 15:25:02 PDT 2022


rjmccall added a comment.

Okay, well, first off, we definitely shouldn't be repeating conditions like `isX86()` all over the place.  What you want to do is to have a general predicate which answers whether we should emit this operation with excess precision; imagine an architecture that wanted to emit `float` operations with `double`.

It looks like you ought to be able to use the abstraction around `BinOpInfo` to good effect here.  You can add a promotion type on the `ScalarExprEmitter` which, if set, tells the emitter that it should actually produce a value of that type.  `EmitBinOps` can recognize that a promotion type is already set and use that type as the operation type instead of the formal type of the expression.  If a promotion type isn't set on the emitter, `EmitBinOps` can try to recognize that it's in the case where it needs a promotion type; it would then set a promotion type before evaluating the operands, but then truncate the result (and clear the promotion type) before returning.  The logic around compound assignment will take some care (and good testing), but it should work the same basic way, and similarly in the complex emitter.


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

https://reviews.llvm.org/D113107



More information about the llvm-commits mailing list