Skip to content

[Strings] Add a string-builtins feature, and lift/lower automatically when enabled #7601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test
  • Loading branch information
kripken committed May 15, 2025
commit 48f05f79c3ecd4c2b4db58e2d67569e9e5ddfbb0
15 changes: 15 additions & 0 deletions test/unit/test_passes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,18 @@ def test_O3_O1(self):

self.assertNotIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O1']))
self.assertNotIn(PASS_IN_O3_ONLY, self.get_passes_run(['-O1', '-O1']))

def test_string_builtins(self):
# When we enable string builtins, we lift early and lower late, and
# only do each once even if there are multiple -O2 operations.
passes = self.get_passes_run(['-O2', '-O2', '-all'])
self.assertEqual(passes.count('string-lifting'), 1)
self.assertEqual(passes.count('string-lowering'), 1)

# Other passes appear twice or more.
self.assertGreater(passes.count('precompute'), 1)

# Without the feature, we do not lift or lower.
passes = self.get_passes_run(['-O2', '-O2', '-all', '--disable-string-builtins'])
self.assertEqual(passes.count('string-lifting'), 0)
self.assertEqual(passes.count('string-lowering'), 0)