1; RUN: llc -mtriple=i686-linux-gnu -o - %s | FileCheck %s
2
3@var = global i128 0
4
5; We were trying to convert the i128 operation into a libcall, but failing to
6; perform sret demotion when we couldn't return the result in registers. Make
7; sure we marshal the return properly:
8
9define void @test_sret_libcall(i128 %l, i128 %r) {
10; CHECK-LABEL: test_sret_libcall:
11
12  ; Stack for call: 4(sret ptr), 16(i128 %l), 16(128 %r). So next logical
13  ; (aligned) place for the actual sret data is %esp + 20.
14; CHECK: leal 20(%esp), [[SRET_ADDR:%[a-z]+]]
15; CHECK: pushl 72(%esp)
16; CHECK: pushl 72(%esp)
17; CHECK: pushl 72(%esp)
18; CHECK: pushl 72(%esp)
19; CHECK: pushl 72(%esp)
20; CHECK: pushl 72(%esp)
21; CHECK: pushl 72(%esp)
22; CHECK: pushl 72(%esp)
23; CHECK: pushl [[SRET_ADDR]]
24
25; CHECK: calll __multi3
26
27; CHECK: addl $44, %esp
28; CHECK-DAG: movl 8(%esp), [[RES0:%[a-z]+]]
29; CHECK-DAG: movl 12(%esp), [[RES1:%[a-z]+]]
30; CHECK-DAG: movl 16(%esp), [[RES2:%[a-z]+]]
31; CHECK-DAG: movl 20(%esp), [[RES3:%[a-z]+]]
32; CHECK-DAG: movl [[RES0]], var
33; CHECK-DAG: movl [[RES1]], var+4
34; CHECK-DAG: movl [[RES2]], var+8
35; CHECK-DAG: movl [[RES3]], var+12
36  %prod = mul i128 %l, %r
37  store i128 %prod, i128* @var
38  ret void
39}
40