Izaron added inline comments.

================
Comment at: clang/lib/AST/ExprConstant.cpp:12452
+    int Ilogb;
+    if (APFloat::opStatus St = ilogb(F, Ilogb); !isConstantOpStatus(St))
+      return false;
----------------
aaron.ballman wrote:
> jcranmer-intel wrote:
> > `long double` is `ppc_fp128` on at least some PPC targets, and while I'm 
> > not entirely certain of what `ilogb` properly returns in the corner cases 
> > of the `ppc_fp128`, I'm not entirely confident that the implementation of 
> > `APFloat` is correct in those cases. I'd like someone with PPC background 
> > to comment in here.
> Paging @hubert.reinterpretcast for help finding a good person to comment on 
> the PPC questions.
@jcranmer-intel constexpr evaluation is quite machine-/target-independent. 
Clang evaluates it based on its **internal** representation of float variables.

[[ 
https://github.com/llvm/llvm-project/blob/2e5bf4da99a2f8d3d4bb4f1a4d1ed968a01e8f02/llvm/include/llvm/ADT/APFloat.h#L1256
 | int ilogb ]] uses `Arg.getIEEE()`, that [[ 
https://github.com/llvm/llvm-project/blob/2e5bf4da99a2f8d3d4bb4f1a4d1ed968a01e8f02/llvm/include/llvm/ADT/APFloat.h#L819-L825
 | returns Clang's internal float representation ]].

Whichever float semantics is being used, [[ 
https://github.com/llvm/llvm-project/blob/2e5bf4da99a2f8d3d4bb4f1a4d1ed968a01e8f02/llvm/lib/Support/APFloat.cpp#L54-L61
 | minExponent and maxExponent are representable as APFloatBase::ExponentType 
]], which is `int32_t`:
```
/// A signed type to represent a floating point numbers unbiased exponent.
typedef int32_t ExponentType;
```

We already use `int ilogb` in some constexpr evaluation code: [[ 
https://github.com/llvm/llvm-project/blob/2e5bf4da99a2f8d3d4bb4f1a4d1ed968a01e8f02/clang/lib/AST/ExprConstant.cpp#L14592
 | link ]], it is working correct because it is working on Clang's float 
representations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136568

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

Reply via email to