Page MenuHomePhabricator

[SCEV] Use nowrap flags to infer that start > start - stride in howManyLessThans
AbandonedPublic

Authored by bsmith on May 17 2022, 7:33 AM.

Details

Summary

If the induction variable being looked at has a nowrap increment, then we
can infer that start > start - stride, otherwise the value produced would
be poison.

Diff Detail

Unit TestsFailed

TimeTest
60,110 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,100 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
60,020 msx64 debian > ThreadSanitizer-x86_64.ThreadSanitizer-x86_64::restore_stack.cpp
Script: -- : 'RUN: at line 1'; /var/lib/buildkite-agent/builds/llvm-project/build/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/tsan/../ -O1 /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/tsan/restore_stack.cpp -o /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/tsan/X86_64Config/Output/restore_stack.cpp.tmp && not /var/lib/buildkite-agent/builds/llvm-project/build/projects/compiler-rt/test/tsan/X86_64Config/Output/restore_stack.cpp.tmp 2>&1 | FileCheck /var/lib/buildkite-agent/builds/llvm-project/compiler-rt/test/tsan/restore_stack.cpp

Event Timeline

bsmith created this revision.May 17 2022, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 7:34 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
bsmith requested review of this revision.May 17 2022, 7:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 7:34 AM

It should be noted that I'm not 100% certain this patch is sound so would very much like some guidance here, I'm looking to address the discussion from here as we have hit this case: https://reviews.llvm.org/D105942#inline-1007492. It's not clear to me whether more needs to be done to cope with the fact that we are dealing with a poison value here.

It isn't enough that AddRec is nowrap; you have to prove that the initial value of the AddRec was produced by a nowrap add.

I should probably get https://reviews.llvm.org/D106331 landed, assuming it still applies; forgot I never merged it.

bsmith abandoned this revision.May 18 2022, 3:21 AM

Ah, a quick check suggests your patch also works for our case. I'll abandon this in favour of that one. Thanks!