Page MenuHomePhabricator

[DAG] Turn a wider range of select of constants into math
Needs ReviewPublic

Authored by deadalnix on Jul 29 2022, 5:35 AM.

Details

Reviewers
laytonio
RKSimon
spatel
gchatelet
lei
nemanjai
steven.zhang
Group Reviewers
Restricted Project
Summary
select Cond, 0, C2 --> (zext(not Cond) << log2(C2)) if C2 is a power of 2.
select Cond, C1, C2 --> (zext(Cond) << log2(C1 - C2)) + C2 if C1 -C2 is a power of 2.

This addresses some regressions in D130675 . It is a bit of a mixed bag for PowerPC .

Diff Detail

Unit TestsFailed

TimeTest
60,130 msx64 debian > AddressSanitizer-x86_64-linux-dynamic.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -shared-libasan -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxDynamicConfig/TestCases/Output/scariness_score_test.cpp.tmp
60,110 msx64 debian > AddressSanitizer-x86_64-linux.TestCases::scariness_score_test.cpp
Script: -- : 'RUN: at line 4'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=address -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -gline-tables-only -m64 -O0 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/asan/TestCases/scariness_score_test.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/asan/X86_64LinuxConfig/TestCases/Output/scariness_score_test.cpp.tmp

Event Timeline

deadalnix created this revision.Jul 29 2022, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 5:35 AM
deadalnix requested review of this revision.Jul 29 2022, 5:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 5:35 AM
deadalnix updated this revision to Diff 448634.Jul 29 2022, 8:01 AM

Avoid complex combines when we expect to fold into select_cc

deadalnix added inline comments.Jul 29 2022, 8:19 AM
llvm/test/CodeGen/X86/select.ll
995

Is this good or bad? @RKSimon , @gchatelet ?

deadalnix updated this revision to Diff 448654.Jul 29 2022, 9:06 AM

Fix CodeGen/PowerPC/nofpexcept.ll

Ressurect select Cond, Pow2, 0 --> (zext Cond) << log2(Pow2)

deadalnix edited the summary of this revision. (Show Details)Jul 29 2022, 9:07 AM
RKSimon added inline comments.Aug 2 2022, 5:25 AM
llvm/test/CodeGen/X86/select.ll
995

Probably worse - 3op LEA isn't great on some cpus

deadalnix added inline comments.Aug 5 2022, 7:47 AM
llvm/test/CodeGen/X86/select.ll
995

D131260 will help to lean on that pattern more consistently.

Overall not great for PPC, but not problematic enough for me to stand in the way if this provides improvements on other targets.

Is this still necessary?