[PATCH] D113107: Support of expression granularity for _Float16.
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 23 18:45:48 PDT 2022
rjmccall added inline comments.
================
Comment at: clang/lib/CodeGen/CGExprComplex.cpp:972
+ }
+ }
+ auto result = Visit(const_cast<Expr *>(E));
----------------
The unary operator cases seem to have disappeared from this function.
================
Comment at: clang/lib/CodeGen/CGExprComplex.cpp:977
+ else
+ return CGF.EmitPromotedValue(result, E->getType());
+}
----------------
You don't have to do any promotion if there isn't a promotion type. `result` will already have the right type.
================
Comment at: clang/lib/CodeGen/CGExprComplex.cpp:615
+ ComplexPairTy result = VisitMinus(E, promotionTy);
+ return result;
+}
----------------
zahiraam wrote:
> rjmccall wrote:
> > This is not unpromoting if the original `PromotionType` is null.
> The idea for this change is that we will be coming to this function only if we are returning a "-operand". If we are in the middle of an expression (such as -f *a +b) we would be directly going to VisitMinus from ScalarExprEmitter::EmitPromod, from the switch branch of UnaryMinus and the promotiontype wouldn't be null.
>
Right, but when you're coming from the normal path, `PromotionType` *will* be null. Since you're doing promoted emission for the actual operator, `result` will be a pair of `float`s instead of a pair of `fp16`s, so you need to unpromote that in order to return the pair of `fp16`s that you're required to return when given a null `PromotionType`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113107/new/
https://reviews.llvm.org/D113107
More information about the cfe-commits
mailing list