diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2024-02-14 20:53:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-14 20:53:16 +0800 |
commit | 16a0629e7c16cc1ec1a5066c57be3044a1e00395 (patch) | |
tree | b3559eded97c709c0bb9c46bbb568a9360fc1469 /llvm/unittests/ProfileData/CoverageMappingTest.cpp | |
parent | c5e13840fdc20adce51673a63d5703bf1ed02aba (diff) | |
download | llvm-16a0629e7c16cc1ec1a5066c57be3044a1e00395.zip llvm-16a0629e7c16cc1ec1a5066c57be3044a1e00395.tar.gz llvm-16a0629e7c16cc1ec1a5066c57be3044a1e00395.tar.bz2 |
[ValueTracking] Compute known FPClass from signbit idiom (#80740)
This patch improves `computeKnownFPClass` by using context-sensitive
information from `DomConditionCache`.
The motivation of this patch is to optimize the following case found in
[fmt/format.h](https://github.com/fmtlib/fmt/blob/e17bc67547a66cdd378ca6a90c56b865d30d6168/include/fmt/format.h#L3555-L3566):
```
define float @test(float %x, i1 %cond) {
%i32 = bitcast float %x to i32
%cmp = icmp slt i32 %i32, 0
br i1 %cmp, label %if.then1, label %if.else
if.then1:
%fneg = fneg float %x
br label %if.end
if.else:
br i1 %cond, label %if.then2, label %if.end
if.then2:
br label %if.end
if.end:
%value = phi float [ %fneg, %if.then1 ], [ %x, %if.then2 ], [ %x, %if.else ]
%ret = call float @llvm.fabs.f32(float %value)
ret float %ret
}
```
We can prove the sign bit of %value is always zero. Then the fabs can be
eliminated.
This pattern also exists in cpython/duckdb/oiio/openexr.
Compile-time impact:
https://llvm-compile-time-tracker.com/compare.php?from=f82e0809ba12170e2f648f8a1ac01e78ef06c958&to=041218bf5491996edd828cc15b3aec5a59ddc636&stat=instructions:u
|stage1-O3|stage1-ReleaseThinLTO|stage1-ReleaseLTO-g|stage1-O0-g|stage2-O3|stage2-O0-g|stage2-clang|
|--|--|--|--|--|--|--|
|-0.00%|+0.01%|+0.00%|-0.03%|+0.00%|+0.00%|+0.02%|
Diffstat (limited to 'llvm/unittests/ProfileData/CoverageMappingTest.cpp')
0 files changed, 0 insertions, 0 deletions