Page MenuHomePhabricator

[FPEnv][InstSimplify] Enable more folds for constrained fsub
Needs ReviewPublic

Authored by kpn on Aug 2 2021, 9:19 AM.

Details

Summary

Currently there are optimizations for the fsub instruction that do not fire for a constrained fsub. Add some of these optimizations.

Optimizations that require teaching the IR matchers about the constrained intrinsics are for a future patch.

Diff Detail

Unit TestsFailed

TimeTest
430 msx64 debian > MemProfiler-x86_64-linux-dynamic.TestCases::test_new_load_store.cpp
Script: -- : 'RUN: at line 5'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libsan -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/memprof/TestCases/test_new_load_store.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/memprof/X86_64LinuxDynamicConfig/TestCases/Output/test_new_load_store.cpp.tmp
100 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-cxa-atexit.S
Script: -- : 'RUN: at line 3'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-cxa-atexit.S
90 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-static-initializer.S
Script: -- : 'RUN: at line 7'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-static-initializer.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-static-initializer.S
110 msx64 debian > ORC-x86_64-linux.TestCases/Linux/x86-64::trivial-tls.S
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang -m64 -c -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-tls.S.tmp /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-tls.S

Event Timeline

kpn created this revision.Aug 2 2021, 9:19 AM
kpn requested review of this revision.Aug 2 2021, 9:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2021, 9:19 AM
sepavloff added inline comments.Aug 2 2021, 11:03 AM
llvm/lib/Analysis/InstructionSimplify.cpp
4996–4998

This transformation is valid only if FMF.noNaNs() is set, because it is incorrect if X==SNaN. Similar for other cases below.

kpn updated this revision to Diff 375582.Sep 28 2021, 7:59 AM

Update for review comments. Instructions that are "maytrap" where a SNaN may be seen must not be eliminated.

I've also added tests for transforms that won't fire due to a lack of IR matcher support. We're going through codepaths we weren't before so we're testing what we weren't before.

Please add the test file as a preliminary commit. Then update here to show the code diffs. Also as part of this patch, apply comments on the tests that are intentionally not changing and/or are expected to change later (TODO).

llvm/lib/Analysis/InstructionSimplify.cpp
4996

This clause is going to be repeated in many places. Make it or its inverse a helper function and give it a name (canIgnoreSNAN or mustPreserveSNAN?).

kpn updated this revision to Diff 379117.Oct 12 2021, 11:18 AM

Update for review comments.