1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=instcombine < %s | FileCheck %s
4 declare i32 @passthru_i32(i32 returned)
5 declare ptr @passthru_p8(ptr returned)
6 declare ptr @passthru_p8_from_p32(ptr returned)
7 declare <8 x i8> @passthru_8i8v_from_2i32v(<2 x i32> returned)
9 define i32 @returned_const_int_arg() {
10 ; CHECK-LABEL: @returned_const_int_arg(
11 ; CHECK-NEXT: [[X:%.*]] = call i32 @passthru_i32(i32 42)
12 ; CHECK-NEXT: ret i32 42
14 %x = call i32 @passthru_i32(i32 42)
18 define ptr @returned_const_ptr_arg() {
19 ; CHECK-LABEL: @returned_const_ptr_arg(
20 ; CHECK-NEXT: [[X:%.*]] = call ptr @passthru_p8(ptr null)
21 ; CHECK-NEXT: ret ptr null
23 %x = call ptr @passthru_p8(ptr null)
27 define ptr @returned_const_ptr_arg_casted() {
28 ; CHECK-LABEL: @returned_const_ptr_arg_casted(
29 ; CHECK-NEXT: [[X:%.*]] = call ptr @passthru_p8_from_p32(ptr null)
30 ; CHECK-NEXT: ret ptr null
32 %x = call ptr @passthru_p8_from_p32(ptr null)
36 define ptr @returned_ptr_arg_casted(ptr %a) {
37 ; CHECK-LABEL: @returned_ptr_arg_casted(
38 ; CHECK-NEXT: [[X:%.*]] = call ptr @passthru_p8_from_p32(ptr [[A:%.*]])
39 ; CHECK-NEXT: ret ptr [[A]]
41 %x = call ptr @passthru_p8_from_p32(ptr %a)
45 @GV = constant <2 x i32> zeroinitializer
46 define <8 x i8> @returned_const_vec_arg_casted() {
47 ; CHECK-LABEL: @returned_const_vec_arg_casted(
48 ; CHECK-NEXT: [[X:%.*]] = call <8 x i8> @passthru_8i8v_from_2i32v(<2 x i32> zeroinitializer)
49 ; CHECK-NEXT: ret <8 x i8> zeroinitializer
51 %v = load <2 x i32>, ptr @GV
52 %x = call <8 x i8> @passthru_8i8v_from_2i32v(<2 x i32> %v)
56 define <8 x i8> @returned_vec_arg_casted(<2 x i32> %a) {
57 ; CHECK-LABEL: @returned_vec_arg_casted(
58 ; CHECK-NEXT: [[X:%.*]] = bitcast <2 x i32> [[A:%.*]] to <8 x i8>
59 ; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i8> @passthru_8i8v_from_2i32v(<2 x i32> [[A]])
60 ; CHECK-NEXT: ret <8 x i8> [[X]]
62 %x = call <8 x i8> @passthru_8i8v_from_2i32v(<2 x i32> %a)
66 define i32 @returned_var_arg(i32 %arg) {
67 ; CHECK-LABEL: @returned_var_arg(
68 ; CHECK-NEXT: [[X:%.*]] = call i32 @passthru_i32(i32 [[ARG:%.*]])
69 ; CHECK-NEXT: ret i32 [[ARG]]
71 %x = call i32 @passthru_i32(i32 %arg)
75 define i32 @returned_const_int_arg_musttail(i32 %arg) {
76 ; CHECK-LABEL: @returned_const_int_arg_musttail(
77 ; CHECK-NEXT: [[X:%.*]] = musttail call i32 @passthru_i32(i32 42)
78 ; CHECK-NEXT: ret i32 [[X]]
80 %x = musttail call i32 @passthru_i32(i32 42)
84 define i32 @returned_var_arg_musttail(i32 %arg) {
85 ; CHECK-LABEL: @returned_var_arg_musttail(
86 ; CHECK-NEXT: [[X:%.*]] = musttail call i32 @passthru_i32(i32 [[ARG:%.*]])
87 ; CHECK-NEXT: ret i32 [[X]]
89 %x = musttail call i32 @passthru_i32(i32 %arg)