[PATCH] D113107: Support of expression granularity for _Float16.
Zahira Ammarguellat via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 12:44:08 PDT 2022
zahiraam added inline comments.
================
Comment at: clang/lib/CodeGen/CGExprComplex.cpp:609
+ ComplexPairTy Op;
+ PromotionType = getPromotionType(E->getSubExpr()->getType());
+ if (!PromotionType.isNull())
----------------
rjmccall wrote:
> This is overwriting the argument, so the code below doesn't understand whether it's supposed to be emitting a promoted result or not. You can test this with something like:
>
> ```
> cf16 = -cf16;
> ```
>
> Here the context does not want a promoted result, but you will produce one anyway.
>
> Because this operator does its own arithmetic, like the binary operators, it needs to follow the same basic logic:
> - remember whether you're supposed to emit a promoted result
> - if not, check whether you should do the arithmetic promoted anyway
> - if you did the arithmetic promoted, but you're not supposed to emit a promoted result, unpromote the result
So something like this:
#define HANDLEUNOP(OP) \
Value *VisitUnary##OP(const UnaryOperator *E, \
QualType PromotionType = QualType()) { \
QualType promotionTy = getPromotionType(E->getSubExpr()->getType()); \
llvvm::Value *result = **Visit##OP**(E, promotionTy); \
result = EmitUnpromotion(promotionTy, E, result);
}
HANDLEUNOP(Minus)
HANDLEUNOP(Plus)
HANDLEUNOP(Imag)
HANDLEUNOP(Reg)
#undef HANDLEUNOP
Where Visit##* are the bodies taken from the current VisitUnary*?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113107/new/
https://reviews.llvm.org/D113107
More information about the llvm-commits
mailing list