1 ; RUN: opt -passes=instcombine -S %s | FileCheck %s
3 ; The intent of this test is to check that the declarations produces for
4 ; libcalls retains the inreg parameter attribute.
6 target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
7 target triple = "i386-unknown-linux-gnu"
10 declare i32 @memcmp(ptr inreg nocapture noundef, ptr inreg nocapture noundef, i32 inreg noundef)
11 declare i32 @printf(ptr, ...)
12 declare double @exp2(double)
13 declare i32 @__sprintf_chk(ptr, i32, i32, ptr, ...)
14 @a = common global [60 x i8] zeroinitializer, align 1
15 @b = common global [60 x i8] zeroinitializer, align 1
16 @h = constant [2 x i8] c"h\00"
18 ; CHECK: declare i32 @bcmp(ptr inreg nocapture, ptr inreg nocapture, i32 inreg)
19 ; CHECK-NOT: declare i32 @bcmp(ptr nocapture, ptr nocapture, i32)
21 define i32 @baz(ptr inreg noundef %s2, i32 inreg noundef %n){
22 %call = call ptr @foo()
23 %call1 = call i32 @memcmp(ptr inreg noundef %call, ptr inreg noundef %s2, i32 inreg noundef %n)
24 %cmp = icmp eq i32 %call1, 0
25 %conv = zext i1 %cmp to i32
29 ; CHECK: declare noundef i32 @putchar(i32 inreg noundef)
30 ; CHECK-NOT: declare noundef i32 @putchar(i32 noundef)
32 define void @test_fewer_params_than_num_register_parameters() {
33 call i32 (ptr, ...) @printf(ptr @h)
37 ; CHECK: declare double @ldexp(double, i32 inreg)
38 ; CHECK-NOT: declare double @ldexp(double, i32)
40 define double @test_non_int_params(i16 signext %x) {
41 %conv = sitofp i16 %x to double
42 %ret = call double @exp2(double %conv)
46 ; CHECK: declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...)
47 ; CHECK-NOT: declare noundef i32 @sprintf(ptr inreg noalias nocapture noundef writeonly, ptr inreg nocapture noundef readonly, ...)
48 define i32 @test_variadic() {
49 %ret = call i32 (ptr, i32, i32, ptr, ...) @__sprintf_chk(ptr @a, i32 0, i32 -1, ptr @b)
53 !llvm.module.flags = !{!0}
54 !0 = !{i32 1, !"NumRegisterParameters", i32 3}