From 0c47dfe0ce8e4e0632d155eadb970d9e17d2fbd5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 11 Jan 2005 03:05:03 +0000 Subject: [PATCH] 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. llvm-svn: 19448 --- test/Regression/CodeGen/X86/regpressure.ll | 72 ++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 test/Regression/CodeGen/X86/regpressure.ll diff --git a/test/Regression/CodeGen/X86/regpressure.ll b/test/Regression/CodeGen/X86/regpressure.ll new file mode 100644 index 00000000000..8cb6b0ee5a6 --- /dev/null +++ b/test/Regression/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 +} +