fix rdar://9289583 - fast isel should handle non-canonical commutative binops
[oota-llvm.git] / test / Transforms / ScalarRepl / memset-aggregate.ll
index 3c5b6627bde692becafc02e33f6091cb46350050..5aeefcd13180fa26a8bd049f50411b9ca7efc0b5 100644 (file)
@@ -1,12 +1,13 @@
-; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | grep 'ret i32 16843009'
-; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | not grep alloca
+; PR1226
+; RUN: opt < %s -scalarrepl -S | grep {ret i32 16843009}
+; RUN: opt < %s -scalarrepl -S | not grep alloca
+; RUN: opt < %s -scalarrepl -instcombine -S | grep {ret i16 514}
 
 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
 target triple = "i686-apple-darwin8"
        %struct.bar = type { %struct.foo, i64, double }
        %struct.foo = type { i32, i32 }
 
-implementation   ; Functions:
 
 define i32 @test1(%struct.foo* %P) {
 entry:
@@ -46,3 +47,20 @@ entry:
        %tmp7 = load i32* %tmp6         ; <i32> [#uses=1]
        ret i32 %tmp7
 }
+
+
+       %struct.f = type { i32, i32, i32, i32, i32, i32 }
+
+define i16 @test4() nounwind {
+entry:
+       %A = alloca %struct.f, align 8          ; <%struct.f*> [#uses=3]
+       %0 = getelementptr %struct.f* %A, i32 0, i32 0          ; <i32*> [#uses=1]
+       store i32 1, i32* %0, align 8
+       %1 = getelementptr %struct.f* %A, i32 0, i32 1          ; <i32*> [#uses=1]
+       %2 = bitcast i32* %1 to i8*             ; <i8*> [#uses=1]
+       call void @llvm.memset.i32(i8* %2, i8 2, i32 12, i32 4)
+       %3 = getelementptr %struct.f* %A, i32 0, i32 2          ; <i32*> [#uses=1]
+       %4 = load i32* %3, align 8              ; <i32> [#uses=1]
+       %retval12 = trunc i32 %4 to i16         ; <i16> [#uses=1]
+       ret i16 %retval12
+}