Add test to verify new pass APIs and loop-vectorizer.

This commit is contained in:
Siu Kwan Lam 2013-01-02 17:42:16 -06:00
commit e2ec14bbb9
4 changed files with 496 additions and 0 deletions

38
test/loopvectorize.py Normal file
View 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()