[FPEnv] Generate constrained FP comparisons from clang
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 10 Jan 2020 13:29:24 +0000 (14:29 +0100)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Fri, 10 Jan 2020 13:33:10 +0000 (14:33 +0100)
commit76e9c2a9870e36415eb343d28942a42296f85597
treea3fc7e4b2d49ffa1c9f5a109346f591dc973b6e0
parent9ba151274869c377921a09ba0bd635412da755ef
[FPEnv] Generate constrained FP comparisons from clang

Update the IRBuilder to generate constrained FP comparisons in
CreateFCmp when IsFPConstrained is true, similar to the other
places in the IRBuilder.

Also, add a new CreateFCmpS to emit signaling FP comparisons,
and use it in clang where comparisons are supposed to be signaling
(currently, only when emitting code for the <, <=, >, >= operators).

Note that there is currently no way to add fast-math flags to a
constrained FP comparison, since this is implemented as an intrinsic
call that returns a boolean type, and FMF are only allowed for calls
returning a floating-point type. However, given the discussion around
https://bugs.llvm.org/show_bug.cgi?id=42179, it seems that FCmp itself
really shouldn't have any FMF either, so this is probably OK.

Reviewed by: craig.topper

Differential Revision: https://reviews.llvm.org/D71467
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/fpconstrained-cmp-double.c [new file with mode: 0644]
clang/test/CodeGen/fpconstrained-cmp-float.c [new file with mode: 0644]
llvm/include/llvm/IR/IRBuilder.h