aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/regpressure.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-11 03:05:03 +0000
committerChris Lattner <sabre@nondot.org>2005-01-11 03:05:03 +0000
commit61b8c9bf94fdfb33c5bfd72458feaa77762aa72c (patch)
treebfac6f1fef163a90f03f17f7c87a8e59e62ffb08 /test/CodeGen/X86/regpressure.ll
parente9c44cdf18b1235841a5d8bfeb07bee9f5699b9a (diff)
The pattern isel is aggressively codegen'ing all of the loads in these
functions together at the start of the basic block, causing massive spillage. The old isel codegened the loads wherever they happened to land, so it generated good code for the first case, but bad code for the second. We really want the pattern isel to generate (the same) good code for both. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19448 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/X86/regpressure.ll')
-rw-r--r--test/CodeGen/X86/regpressure.ll72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/CodeGen/X86/regpressure.ll b/test/CodeGen/X86/regpressure.ll
new file mode 100644
index 0000000000..8cb6b0ee5a
--- /dev/null
+++ b/test/CodeGen/X86/regpressure.ll
@@ -0,0 +1,72 @@
+;; Both functions in this testcase should codegen to the same function, and
+;; neither of them should require spilling anything to the stack.
+
+; RUN: llvm-as < %s | llc -march=x86 -disable-pattern-isel=0 -stats 2>&1 | not grep 'Number of register spills'
+
+;; This can be compiled to use three registers if the loads are not
+;; folded into the multiplies, 2 registers otherwise.
+int %regpressure1(int* %P) {
+ %A = load int* %P
+ %Bp = getelementptr int* %P, int 1
+ %B = load int* %Bp
+ %s1 = mul int %A, %B
+ %Cp = getelementptr int* %P, int 2
+ %C = load int* %Cp
+ %s2 = mul int %s1, %C
+ %Dp = getelementptr int* %P, int 3
+ %D = load int* %Dp
+ %s3 = mul int %s2, %D
+ %Ep = getelementptr int* %P, int 4
+ %E = load int* %Ep
+ %s4 = mul int %s3, %E
+ %Fp = getelementptr int* %P, int 5
+ %F = load int* %Fp
+ %s5 = mul int %s4, %F
+ %Gp = getelementptr int* %P, int 6
+ %G = load int* %Gp
+ %s6 = mul int %s5, %G
+ %Hp = getelementptr int* %P, int 7
+ %H = load int* %Hp
+ %s7 = mul int %s6, %H
+ %Ip = getelementptr int* %P, int 8
+ %I = load int* %Ip
+ %s8 = mul int %s7, %I
+ %Jp = getelementptr int* %P, int 9
+ %J = load int* %Jp
+ %s9 = mul int %s8, %J
+ ret int %s9
+}
+
+;; This testcase should produce identical code to the test above.
+int %regpressure2(int* %P) {
+ %A = load int* %P
+ %Bp = getelementptr int* %P, int 1
+ %B = load int* %Bp
+ %Cp = getelementptr int* %P, int 2
+ %C = load int* %Cp
+ %Dp = getelementptr int* %P, int 3
+ %D = load int* %Dp
+ %Ep = getelementptr int* %P, int 4
+ %E = load int* %Ep
+ %Fp = getelementptr int* %P, int 5
+ %F = load int* %Fp
+ %Gp = getelementptr int* %P, int 6
+ %G = load int* %Gp
+ %Hp = getelementptr int* %P, int 7
+ %H = load int* %Hp
+ %Ip = getelementptr int* %P, int 8
+ %I = load int* %Ip
+ %Jp = getelementptr int* %P, int 9
+ %J = load int* %Jp
+ %s1 = mul int %A, %B
+ %s2 = mul int %s1, %C
+ %s3 = mul int %s2, %D
+ %s4 = mul int %s3, %E
+ %s5 = mul int %s4, %F
+ %s6 = mul int %s5, %G
+ %s7 = mul int %s6, %H
+ %s8 = mul int %s7, %I
+ %s9 = mul int %s8, %J
+ ret int %s9
+}
+