Implement PR3495: local spiller optimization. The local spiller can now keep availabi...
[oota-llvm.git] / test / CodeGen / X86 / coalescer-commute2.ll
index f90ab9e3d5eef247778055eef7a9801bbb682f4c..ce4abf1d31ab2f0659a1f60412ea3f71e75e9f28 100644 (file)
@@ -1,21 +1,34 @@
-; RUN: llvm-as < %s | llc -mtriple=i686-apple-darwin -mattr=+sse2 -coalescer-commute-instrs | grep movsd | count 4
+; RUN: llvm-as < %s | llc -march=x86-64 | grep paddw | count 2
+; RUN: llvm-as < %s | llc -march=x86-64 | not grep mov
 
-define i32 @main(i32 %argc, i8** %argv) nounwind  {
+; The 2-addr pass should ensure that identical code is produced for these functions
+; no extra copy should be generated.
+
+define <2 x i64> @test1(<2 x i64> %x, <2 x i64> %y) nounwind  {
 entry:
-       br label %bb145.us.i.i
+       %tmp6 = bitcast <2 x i64> %y to <8 x i16>               ; <<8 x i16>> [#uses=1]
+       %tmp8 = bitcast <2 x i64> %x to <8 x i16>               ; <<8 x i16>> [#uses=1]
+       %tmp9 = add <8 x i16> %tmp8, %tmp6              ; <<8 x i16>> [#uses=1]
+       %tmp10 = bitcast <8 x i16> %tmp9 to <2 x i64>           ; <<2 x i64>> [#uses=1]
+       ret <2 x i64> %tmp10
+}
 
-bb145.us.i.i:          ; preds = %bb145.us.i.i, %entry
-       %seed.3.reg2mem.0.us.i.i = phi double [ 0.000000e+00, %entry ], [ %tmp9.i.us.i.i, %bb145.us.i.i ]               ; <double> [#uses=1]
-       %tmp2.i13.us.i.i = mul double %seed.3.reg2mem.0.us.i.i, 1.680700e+04            ; <double> [#uses=1]
-       %tmp3.i.us.i.i = add double %tmp2.i13.us.i.i, 1.000000e+00              ; <double> [#uses=1]
-       %tmp6.i15.us.i.i = call double @floor( double 0.000000e+00 ) nounwind readnone          ; <double> [#uses=1]
-       %tmp7.i16.us.i.i = mul double %tmp6.i15.us.i.i, 0xC1DFFFFFFFC00000              ; <double> [#uses=1]
-       %tmp9.i.us.i.i = add double %tmp7.i16.us.i.i, %tmp3.i.us.i.i            ; <double> [#uses=2]
-       %tmp5.i12.us.i.i = mul double %tmp9.i.us.i.i, 2.000000e+00              ; <double> [#uses=1]
-       %tmp6.i.us.i.i = fdiv double %tmp5.i12.us.i.i, 0x41DFFFFFFFC00000               ; <double> [#uses=1]
-       %tmp8.i.us.i.i = add double %tmp6.i.us.i.i, -1.000000e+00               ; <double> [#uses=1]
-       store double %tmp8.i.us.i.i, double* null, align 8
-       br label %bb145.us.i.i
+define <2 x i64> @test2(<2 x i64> %x, <2 x i64> %y) nounwind  {
+entry:
+       %tmp6 = bitcast <2 x i64> %x to <8 x i16>               ; <<8 x i16>> [#uses=1]
+       %tmp8 = bitcast <2 x i64> %y to <8 x i16>               ; <<8 x i16>> [#uses=1]
+       %tmp9 = add <8 x i16> %tmp8, %tmp6              ; <<8 x i16>> [#uses=1]
+       %tmp10 = bitcast <8 x i16> %tmp9 to <2 x i64>           ; <<2 x i64>> [#uses=1]
+       ret <2 x i64> %tmp10
+}
+
+
+; The coalescer should commute the add to avoid a copy.
+define <4 x float> @test3(<4 x float> %V) {
+entry:
+        %tmp8 = shufflevector <4 x float> %V, <4 x float> undef,
+                                        <4 x i32> < i32 3, i32 2, i32 1, i32 0 >
+        %add = add <4 x float> %tmp8, %V
+        ret <4 x float> %add
 }
 
-declare double @floor(double) nounwind readnone