[opaque pointer type] Add textual IR support for explicit type parameter to gep operator
[oota-llvm.git] / test / Transforms / InstCombine / puts-1.ll
1 ; Test that the puts library call simplifier works correctly.
2 ;
3 ; RUN: opt < %s -instcombine -S | FileCheck %s
4
5 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-f80:128:128"
6
7 @empty = constant [1 x i8] zeroinitializer
8
9 declare i32 @puts(i8*)
10
11 ; Check puts("") -> putchar('\n').
12
13 define void @test_simplify1() {
14 ; CHECK-LABEL: @test_simplify1(
15   %str = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
16   call i32 @puts(i8* %str)
17 ; CHECK-NEXT: call i32 @putchar(i32 10)
18   ret void
19 ; CHECK-NEXT: ret void
20 }
21
22 ; Don't simplify if the return value is used.
23
24 define i32 @test_no_simplify1() {
25 ; CHECK-LABEL: @test_no_simplify1(
26   %str = getelementptr [1 x i8], [1 x i8]* @empty, i32 0, i32 0
27   %ret = call i32 @puts(i8* %str)
28 ; CHECK-NEXT: call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @empty, i32 0, i32 0))
29   ret i32 %ret
30 ; CHECK-NEXT: ret i32 %ret
31 }