Add test to verify new pass APIs and loop-vectorizer.
This commit is contained in:
parent
7f9c91e2aa
commit
e2ec14bbb9
4 changed files with 496 additions and 0 deletions
38
test/loopvectorize.py
Normal file
38
test/loopvectorize.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from llvm.core import *
|
||||
from llvm.passes import *
|
||||
from llvm.ee import *
|
||||
from os.path import dirname, join as join_path
|
||||
|
||||
import unittest
|
||||
import re
|
||||
|
||||
class TestLoopVectorizer(unittest.TestCase):
|
||||
def test_loop_vectorizer(self):
|
||||
|
||||
re_vector = re.compile("<\d+ x \w+>")
|
||||
|
||||
tm = TargetMachine.new(opt=3)
|
||||
|
||||
# Build passes
|
||||
pm = build_pass_managers(tm, opt=3, loop_vectorize=True, fpm=False).pm
|
||||
|
||||
# Load test module
|
||||
asmfile = join_path(dirname(__file__), 'loopvectorize.ll')
|
||||
with open(asmfile) as asm:
|
||||
mod = Module.from_assembly(asm)
|
||||
|
||||
before = str(mod)
|
||||
|
||||
pm.run(mod)
|
||||
|
||||
after = str(mod)
|
||||
self.assertNotEqual(after, before)
|
||||
|
||||
before_vectors = re_vector.findall(before)
|
||||
self.assertFalse(before_vectors)
|
||||
after_vectors = re_vector.findall(after)
|
||||
self.assertLess(len(before_vectors), len(after_vectors))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue