[PATCH] D43142: Experimental pass to convert all floating point operations to the equivalent constrained intrinsics

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 1 11:24:44 PDT 2018


cameron.mcinally added a comment.

In https://reviews.llvm.org/D43142#1284190, @kpn wrote:

> And couldn't we turn off constant folding in the IRBuilder when necessary?


I don't think that would work in all cases. E.g. a binary operator with two constant operands.

  int main() {
    float z = 5.0/0.0;
    return z;
  }

Well, not without a considerable effort to rework the IRBuilder at least. I'm fairly sure we can't produce an Instruction with two Constant operands right now.

> Plus, we still have to deal with inlining being done llvm-side. We don't know in clang what llvm will inline. And we don't want an inlined function's instructions moved in between use of constrained intrinsics, for example.

That's undefined behavior. A translation unit that checks or modifies the FP Environment must set the FENV_ACCESS pragma to ON. When it is set to ON, only constrained intrinsics should be generated from Clang. If it is unset or set to OFF, any FP Environment access causes undefined behavior.

It's unclear to me how LTO (or other cross file inlining) would work here. I haven't given it much though until now. My knee-jerk reaction is that we shouldn't be inlining from a FENV_ACCESS=OFF to FENV_ACCESS=ON location.


https://reviews.llvm.org/D43142





More information about the llvm-commits mailing list