aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2022-07-26 15:31:12 -0400
committerSanjay Patel <spatel@rotateright.com>2022-07-26 15:50:14 -0400
commite3205b87655f07d70c7e7f8a86b2d009c0432e49 (patch)
tree00b89d6848cba8c4784eb72cf8515a2e1a73e181 /clang/lib/CodeGen/CodeGenModule.cpp
parent114df244ec50ce0145702974335965c3aa2c3dcc (diff)
downloadllvm-e3205b87655f07d70c7e7f8a86b2d009c0432e49.zip
llvm-e3205b87655f07d70c7e7f8a86b2d009c0432e49.tar.gz
llvm-e3205b87655f07d70c7e7f8a86b2d009c0432e49.tar.bz2
[AggressiveInstCombine] convert sqrt libcalls with "nnan" to sqrt intrinsics
This is an alternate to D129155 that uses TTI.haveFastSqrt() to avoid a potential miscompile for programs with reads of errno. Moving the transform to AggressiveInstCombine provides access to TTI. If a sqrt call has "nnan", that implies that the input argument is never negative because sqrt of {negative number} --> NAN. If the argument is never negative and the call can be lowered without a libcall, then we can assume that errno accesses are unchanged after lowering, so the call can be translated to the LLVM intrinsic (which is expected to become inline code). This affects codegen for targets like x86 that have sqrt instructions, but still have to conservatively assume that a libcall may be needed to set errno as shown in issue #52620 and issue #56383. This patch won't solve those examples - we will need to extend this to use CannotBeOrderedLessThanZero or similar, enhance that analysis for new operators, and/or deal with llvm.assume too. Differential Revision: https://reviews.llvm.org/D129167
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions