1; RUN: opt -instcombine -S < %s | FileCheck %s
2; RUN: opt -debugify-each -instcombine -S < %s | FileCheck %s
3
4; These are both direct calls, but make sure instcombine leaves the casts
5; alone.
6
7define i32 @call_thunk(i32 %x, i32 %y) {
8  %r = call i32 bitcast (void (i32, ...)* @inc_first_arg_thunk to i32 (i32, i32)*)(i32 %x, i32 %y)
9  ret i32 %r
10}
11
12; CHECK-LABEL: define i32 @call_thunk(i32 %x, i32 %y)
13; CHECK:   %r = call i32 bitcast (void (i32, ...)* @inc_first_arg_thunk to i32 (i32, i32)*)(i32 %x, i32 %y)
14; CHECK:   ret i32 %r
15
16define internal void @inc_first_arg_thunk(i32 %arg1, ...) #0 {
17entry:
18  %inc = add i32 %arg1, 1
19  musttail call void (i32, ...) bitcast (i32 (i32, i32)* @plus to void (i32, ...)*)(i32 %inc, ...)
20  ret void
21}
22
23; CHECK-LABEL: define internal void @inc_first_arg_thunk(i32 %arg1, ...) #0
24; CHECK:   %inc = add i32 %arg1, 1
25; CHECK:   musttail call void (i32, ...) bitcast (i32 (i32, i32)* @plus to void (i32, ...)*)(i32 %inc, ...)
26; CHECK:   ret void
27
28define internal i32 @plus(i32 %x, i32 %y) {
29  %r = add i32 %x, %y
30  ret i32 %r
31}
32
33attributes #0 = { "thunk" }
34