From 557a143b8276ef8e07f2e873d7a2988106474e9a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 May 2002 21:34:22 +0000 Subject: [PATCH] Add some simple test of reassociation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2555 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/Reassociate/Makefile | 10 ++++++++ test/Transforms/Reassociate/basictest.ll | 12 +++++++++ test/Transforms/Reassociate/basictest2.ll | 13 ++++++++++ test/Transforms/Reassociate/otherops.ll | 31 +++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 test/Transforms/Reassociate/Makefile create mode 100644 test/Transforms/Reassociate/basictest.ll create mode 100644 test/Transforms/Reassociate/basictest2.ll create mode 100644 test/Transforms/Reassociate/otherops.ll diff --git a/test/Transforms/Reassociate/Makefile b/test/Transforms/Reassociate/Makefile new file mode 100644 index 00000000000..91acd4d481b --- /dev/null +++ b/test/Transforms/Reassociate/Makefile @@ -0,0 +1,10 @@ + +LEVEL = ../../../.. +include $(LEVEL)/test/Makefile.tests + +TESTS := $(wildcard *.ll) + +all:: $(addprefix Output/, $(TESTS:%.ll=%.ll.out)) + +Output/%.ll.out: %.ll Output/.dir $(LOPT) + -$(TESTRUNR) $< diff --git a/test/Transforms/Reassociate/basictest.ll b/test/Transforms/Reassociate/basictest.ll new file mode 100644 index 00000000000..ac5932053fd --- /dev/null +++ b/test/Transforms/Reassociate/basictest.ll @@ -0,0 +1,12 @@ +; With reassociation, constant folding can eliminate the 12 and -12 constants. +; +; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep add +; RUN: then exit 1 +; RUN: else exit 0 +; RUN: fi + +int "test"(int %arg) { + %tmp1 = sub int -12, %arg + %tmp2 = add int %tmp1, 12 + ret int %tmp2 +} diff --git a/test/Transforms/Reassociate/basictest2.ll b/test/Transforms/Reassociate/basictest2.ll new file mode 100644 index 00000000000..192b8d3d086 --- /dev/null +++ b/test/Transforms/Reassociate/basictest2.ll @@ -0,0 +1,13 @@ +; With reassociation, constant folding can eliminate the +/- 30 constants. +; +; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep 30 +; RUN: then exit 1 +; RUN: else exit 0 +; RUN: fi + +int "test"(int %reg109, int %reg1111) { + %reg115 = add int %reg109, -30 ; [#uses=1] + %reg116 = add int %reg115, %reg1111 ; [#uses=1] + %reg117 = add int %reg116, 30 ; [#uses=1] + ret int %reg117 +} diff --git a/test/Transforms/Reassociate/otherops.ll b/test/Transforms/Reassociate/otherops.ll new file mode 100644 index 00000000000..7182e1f72ac --- /dev/null +++ b/test/Transforms/Reassociate/otherops.ll @@ -0,0 +1,31 @@ +; Reassociation should apply to Add, Mul, And, Or, & Xor +; +; RUN: if as < %s | opt -reassociate -constprop -instcombine -die | dis | grep 12 +; RUN: then exit 1 +; RUN: else exit 0 +; RUN: fi + +int "test_mul"(int %arg) { + %tmp1 = mul int 12, %arg + %tmp2 = mul int %tmp1, 12 + ret int %tmp2 +} + +int "test_and"(int %arg) { + %tmp1 = and int 14, %arg + %tmp2 = and int %tmp1, 14 + ret int %tmp2 +} + +int "test_or"(int %arg) { + %tmp1 = or int 14, %arg + %tmp2 = or int %tmp1, 14 + ret int %tmp2 +} + +int "test_xor"(int %arg) { + %tmp1 = xor int 12, %arg + %tmp2 = xor int %tmp1, 12 + ret int %tmp2 +} + -- 2.34.1