Home | History | Annotate | Download | only in X86
      1 ; REQUIRES: asserts
      2 ;; Both functions in this testcase should codegen to the same function, and
      3 ;; neither of them should require spilling anything to the stack.
      4 
      5 ; RUN: llc < %s -march=x86 -stats 2>&1 | \
      6 ; RUN:   not grep "Number of register spills"
      7 
      8 ;; This can be compiled to use three registers if the loads are not
      9 ;; folded into the multiplies, 2 registers otherwise.
     10 
     11 define i32 @regpressure1(i32* %P) {
     12 	%A = load i32, i32* %P		; <i32> [#uses=1]
     13 	%Bp = getelementptr i32, i32* %P, i32 1		; <i32*> [#uses=1]
     14 	%B = load i32, i32* %Bp		; <i32> [#uses=1]
     15 	%s1 = mul i32 %A, %B		; <i32> [#uses=1]
     16 	%Cp = getelementptr i32, i32* %P, i32 2		; <i32*> [#uses=1]
     17 	%C = load i32, i32* %Cp		; <i32> [#uses=1]
     18 	%s2 = mul i32 %s1, %C		; <i32> [#uses=1]
     19 	%Dp = getelementptr i32, i32* %P, i32 3		; <i32*> [#uses=1]
     20 	%D = load i32, i32* %Dp		; <i32> [#uses=1]
     21 	%s3 = mul i32 %s2, %D		; <i32> [#uses=1]
     22 	%Ep = getelementptr i32, i32* %P, i32 4		; <i32*> [#uses=1]
     23 	%E = load i32, i32* %Ep		; <i32> [#uses=1]
     24 	%s4 = mul i32 %s3, %E		; <i32> [#uses=1]
     25 	%Fp = getelementptr i32, i32* %P, i32 5		; <i32*> [#uses=1]
     26 	%F = load i32, i32* %Fp		; <i32> [#uses=1]
     27 	%s5 = mul i32 %s4, %F		; <i32> [#uses=1]
     28 	%Gp = getelementptr i32, i32* %P, i32 6		; <i32*> [#uses=1]
     29 	%G = load i32, i32* %Gp		; <i32> [#uses=1]
     30 	%s6 = mul i32 %s5, %G		; <i32> [#uses=1]
     31 	%Hp = getelementptr i32, i32* %P, i32 7		; <i32*> [#uses=1]
     32 	%H = load i32, i32* %Hp		; <i32> [#uses=1]
     33 	%s7 = mul i32 %s6, %H		; <i32> [#uses=1]
     34 	%Ip = getelementptr i32, i32* %P, i32 8		; <i32*> [#uses=1]
     35 	%I = load i32, i32* %Ip		; <i32> [#uses=1]
     36 	%s8 = mul i32 %s7, %I		; <i32> [#uses=1]
     37 	%Jp = getelementptr i32, i32* %P, i32 9		; <i32*> [#uses=1]
     38 	%J = load i32, i32* %Jp		; <i32> [#uses=1]
     39 	%s9 = mul i32 %s8, %J		; <i32> [#uses=1]
     40 	ret i32 %s9
     41 }
     42 
     43 define i32 @regpressure2(i32* %P) {
     44 	%A = load i32, i32* %P		; <i32> [#uses=1]
     45 	%Bp = getelementptr i32, i32* %P, i32 1		; <i32*> [#uses=1]
     46 	%B = load i32, i32* %Bp		; <i32> [#uses=1]
     47 	%Cp = getelementptr i32, i32* %P, i32 2		; <i32*> [#uses=1]
     48 	%C = load i32, i32* %Cp		; <i32> [#uses=1]
     49 	%Dp = getelementptr i32, i32* %P, i32 3		; <i32*> [#uses=1]
     50 	%D = load i32, i32* %Dp		; <i32> [#uses=1]
     51 	%Ep = getelementptr i32, i32* %P, i32 4		; <i32*> [#uses=1]
     52 	%E = load i32, i32* %Ep		; <i32> [#uses=1]
     53 	%Fp = getelementptr i32, i32* %P, i32 5		; <i32*> [#uses=1]
     54 	%F = load i32, i32* %Fp		; <i32> [#uses=1]
     55 	%Gp = getelementptr i32, i32* %P, i32 6		; <i32*> [#uses=1]
     56 	%G = load i32, i32* %Gp		; <i32> [#uses=1]
     57 	%Hp = getelementptr i32, i32* %P, i32 7		; <i32*> [#uses=1]
     58 	%H = load i32, i32* %Hp		; <i32> [#uses=1]
     59 	%Ip = getelementptr i32, i32* %P, i32 8		; <i32*> [#uses=1]
     60 	%I = load i32, i32* %Ip		; <i32> [#uses=1]
     61 	%Jp = getelementptr i32, i32* %P, i32 9		; <i32*> [#uses=1]
     62 	%J = load i32, i32* %Jp		; <i32> [#uses=1]
     63 	%s1 = mul i32 %A, %B		; <i32> [#uses=1]
     64 	%s2 = mul i32 %s1, %C		; <i32> [#uses=1]
     65 	%s3 = mul i32 %s2, %D		; <i32> [#uses=1]
     66 	%s4 = mul i32 %s3, %E		; <i32> [#uses=1]
     67 	%s5 = mul i32 %s4, %F		; <i32> [#uses=1]
     68 	%s6 = mul i32 %s5, %G		; <i32> [#uses=1]
     69 	%s7 = mul i32 %s6, %H		; <i32> [#uses=1]
     70 	%s8 = mul i32 %s7, %I		; <i32> [#uses=1]
     71 	%s9 = mul i32 %s8, %J		; <i32> [#uses=1]
     72 	ret i32 %s9
     73 }
     74 
     75 define i32 @regpressure3(i16* %P, i1 %Cond, i32* %Other) {
     76 	%A = load i16, i16* %P		; <i16> [#uses=1]
     77 	%Bp = getelementptr i16, i16* %P, i32 1		; <i16*> [#uses=1]
     78 	%B = load i16, i16* %Bp		; <i16> [#uses=1]
     79 	%Cp = getelementptr i16, i16* %P, i32 2		; <i16*> [#uses=1]
     80 	%C = load i16, i16* %Cp		; <i16> [#uses=1]
     81 	%Dp = getelementptr i16, i16* %P, i32 3		; <i16*> [#uses=1]
     82 	%D = load i16, i16* %Dp		; <i16> [#uses=1]
     83 	%Ep = getelementptr i16, i16* %P, i32 4		; <i16*> [#uses=1]
     84 	%E = load i16, i16* %Ep		; <i16> [#uses=1]
     85 	%Fp = getelementptr i16, i16* %P, i32 5		; <i16*> [#uses=1]
     86 	%F = load i16, i16* %Fp		; <i16> [#uses=1]
     87 	%Gp = getelementptr i16, i16* %P, i32 6		; <i16*> [#uses=1]
     88 	%G = load i16, i16* %Gp		; <i16> [#uses=1]
     89 	%Hp = getelementptr i16, i16* %P, i32 7		; <i16*> [#uses=1]
     90 	%H = load i16, i16* %Hp		; <i16> [#uses=1]
     91 	%Ip = getelementptr i16, i16* %P, i32 8		; <i16*> [#uses=1]
     92 	%I = load i16, i16* %Ip		; <i16> [#uses=1]
     93 	%Jp = getelementptr i16, i16* %P, i32 9		; <i16*> [#uses=1]
     94 	%J = load i16, i16* %Jp		; <i16> [#uses=1]
     95 	%A.upgrd.1 = sext i16 %A to i32		; <i32> [#uses=1]
     96 	%B.upgrd.2 = sext i16 %B to i32		; <i32> [#uses=1]
     97 	%D.upgrd.3 = sext i16 %D to i32		; <i32> [#uses=1]
     98 	%C.upgrd.4 = sext i16 %C to i32		; <i32> [#uses=1]
     99 	%E.upgrd.5 = sext i16 %E to i32		; <i32> [#uses=1]
    100 	%F.upgrd.6 = sext i16 %F to i32		; <i32> [#uses=1]
    101 	%G.upgrd.7 = sext i16 %G to i32		; <i32> [#uses=1]
    102 	%H.upgrd.8 = sext i16 %H to i32		; <i32> [#uses=1]
    103 	%I.upgrd.9 = sext i16 %I to i32		; <i32> [#uses=1]
    104 	%J.upgrd.10 = sext i16 %J to i32		; <i32> [#uses=1]
    105 	%s1 = add i32 %A.upgrd.1, %B.upgrd.2		; <i32> [#uses=1]
    106 	%s2 = add i32 %C.upgrd.4, %s1		; <i32> [#uses=1]
    107 	%s3 = add i32 %D.upgrd.3, %s2		; <i32> [#uses=1]
    108 	%s4 = add i32 %E.upgrd.5, %s3		; <i32> [#uses=1]
    109 	%s5 = add i32 %F.upgrd.6, %s4		; <i32> [#uses=1]
    110 	%s6 = add i32 %G.upgrd.7, %s5		; <i32> [#uses=1]
    111 	%s7 = add i32 %H.upgrd.8, %s6		; <i32> [#uses=1]
    112 	%s8 = add i32 %I.upgrd.9, %s7		; <i32> [#uses=1]
    113 	%s9 = add i32 %J.upgrd.10, %s8		; <i32> [#uses=1]
    114 	ret i32 %s9
    115 }
    116