brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 498ec52 Raw
65 lines · plain
1; RUN: opt -passes='loop(loop-idiom)' < %s -S | FileCheck %s2 3target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"4target triple = "x86_64-unknown-linux-gnu"5 6; CHECK-LABEL: @strlen(7; CHECK-NOT: call{{.*}} strlen8; CHECK-LABEL: @wcslen(9; CHECK-NOT: call{{.*}} wcslen10 11define i64 @strlen(ptr %str) {12entry:13  br label %while.cond14 15while.cond:16  %str.addr.0 = phi ptr [ %str, %entry ], [ %incdec.ptr, %while.cond ]17  %0 = load i8, ptr %str.addr.0, align 118  %cmp.not = icmp eq i8 %0, 019  %incdec.ptr = getelementptr i8, ptr %str.addr.0, i64 120  br i1 %cmp.not, label %while.end, label %while.cond21 22while.end:23  %sub.ptr.lhs.cast = ptrtoint ptr %str.addr.0 to i6424  %sub.ptr.rhs.cast = ptrtoint ptr %str to i6425  %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast26  ret i64 %sub.ptr.sub27}28 29define i64 @wcslen(ptr %src) {30entry:31  %cmp = icmp eq ptr %src, null32  br i1 %cmp, label %return, label %lor.lhs.false33 34lor.lhs.false:                                    ; preds = %entry35  %0 = load i32, ptr %src, align 436  %cmp1 = icmp eq i32 %0, 037  br i1 %cmp1, label %return, label %while.cond.preheader38 39while.cond.preheader:                             ; preds = %lor.lhs.false40  br label %while.cond41 42while.cond:                                       ; preds = %while.cond.preheader, %while.cond43  %src.pn = phi ptr [ %curr.0, %while.cond ], [ %src, %while.cond.preheader ]44  %curr.0 = getelementptr inbounds i8, ptr %src.pn, i64 445  %1 = load i32, ptr %curr.0, align 446  %tobool.not = icmp eq i32 %1, 047  br i1 %tobool.not, label %while.end, label %while.cond48 49while.end:                                        ; preds = %while.cond50  %curr.0.lcssa = phi ptr [ %curr.0, %while.cond ]51  %sub.ptr.lhs.cast = ptrtoint ptr %curr.0.lcssa to i6452  %sub.ptr.rhs.cast = ptrtoint ptr %src to i6453  %sub.ptr.sub = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast54  %sub.ptr.div = ashr exact i64 %sub.ptr.sub, 255  br label %return56 57return:                                           ; preds = %entry, %lor.lhs.false, %while.end58  %retval.0 = phi i64 [ %sub.ptr.div, %while.end ], [ 0, %lor.lhs.false ], [ 0, %entry ]59  ret i64 %retval.060}61 62 63!llvm.module.flags = !{!0}64!0 = !{i32 1, !"wchar_size", i32 4}65