Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / wmemchr.c
blob36f8002d550a1ca46f871e2c518622524cdbf007
1 // RUN: %clang_cc1 %s -triple x86_64-pc-win32 -emit-llvm -o - | FileCheck %s
3 typedef __SIZE_TYPE__ size_t;
4 typedef __WCHAR_TYPE__ wchar_t;
6 const wchar_t *wmemchr_test(const wchar_t *s, const wchar_t c, size_t n) {
7 // CHECK-LABEL: define dso_local ptr @wmemchr_test
8 // CHECK: [[S:%.*]] = load
9 // CHECK: [[C:%.*]] = load
10 // CHECK: [[N:%.*]] = load
11 // CHECK: [[N0:%.*]] = icmp eq i64 [[N]], 0
12 // CHECK: br i1 [[N0]], label %[[EXIT:.*]], label %[[EQ:.*]]
14 // CHECK: [[EQ]]:
15 // CHECK: [[SP:%.*]] = phi ptr [ [[S]], %[[ENTRY:.*]] ], [ [[SN:.*]], %[[NEXT:.*]] ]
16 // CHECK: [[NP:%.*]] = phi i64 [ [[N]], %[[ENTRY]] ], [ [[NN:.*]], %[[NEXT]] ]
17 // CHECK: [[SL:%.*]] = load i16, ptr [[SP]], align 2
18 // CHECK: [[RES:%.*]] = getelementptr inbounds i16, ptr [[SP]], i32 0
19 // CHECK: [[CMPEQ:%.*]] = icmp eq i16 [[SL]], [[C]]
20 // CHECK: br i1 [[CMPEQ]], label %[[EXIT]], label %[[LT:.*]]
22 // CHECK: [[NEXT]]:
23 // CHECK: [[SN]] = getelementptr inbounds i16, ptr [[SP]], i32 1
24 // CHECK: [[NN]] = sub i64 [[NP]], 1
25 // CHECK: [[NN0:%.*]] = icmp eq i64 [[NN]], 0
26 // CHECK: br i1 [[NN0]], label %[[EXIT]], label %[[EQ]]
28 // CHECK: [[EXIT]]:
29 // CHECK: [[RV:%.*]] = phi ptr [ null, %[[ENTRY]] ], [ null, %[[NEXT]] ], [ [[RES]], %[[EQ]] ]
30 // CHECK: ret ptr [[RV]]
31 return __builtin_wmemchr(s, c, n);