• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %s -argpromotion -sroa -S | FileCheck %s
2
3target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
4
5%struct.ss = type { i32, i32 }
6
7; Argpromote + sroa should change this to passing the two integers by value.
8define internal i32 @f(%struct.ss* inalloca  %s) {
9entry:
10  %f0 = getelementptr %struct.ss, %struct.ss* %s, i32 0, i32 0
11  %f1 = getelementptr %struct.ss, %struct.ss* %s, i32 0, i32 1
12  %a = load i32, i32* %f0, align 4
13  %b = load i32, i32* %f1, align 4
14  %r = add i32 %a, %b
15  ret i32 %r
16}
17; CHECK-LABEL: define internal i32 @f
18; CHECK-NOT: load
19; CHECK: ret
20
21define i32 @main() {
22entry:
23  %S = alloca inalloca %struct.ss
24  %f0 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 0
25  %f1 = getelementptr %struct.ss, %struct.ss* %S, i32 0, i32 1
26  store i32 1, i32* %f0, align 4
27  store i32 2, i32* %f1, align 4
28  %r = call i32 @f(%struct.ss* inalloca %S)
29  ret i32 %r
30}
31; CHECK-LABEL: define i32 @main
32; CHECK-NOT: load
33; CHECK: ret
34
35; Argpromote can't promote %a because of the icmp use.
36define internal i1 @g(%struct.ss* %a, %struct.ss* inalloca %b) nounwind  {
37; CHECK: define internal i1 @g(%struct.ss* %a, %struct.ss* inalloca %b)
38entry:
39  %c = icmp eq %struct.ss* %a, %b
40  ret i1 %c
41}
42
43define i32 @test() {
44entry:
45  %S = alloca inalloca %struct.ss
46  %c = call i1 @g(%struct.ss* %S, %struct.ss* inalloca %S)
47; CHECK: call i1 @g(%struct.ss* %S, %struct.ss* inalloca %S)
48  ret i32 0
49}
50