brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · aaa72dd Raw
51 lines · plain
1; Test that the strspn library call simplifier works correctly.2;3; RUN: opt < %s -passes=instcombine -S | FileCheck %s4 5@abcba = constant [6 x i8] c"abcba\00"6@abc = constant [4 x i8] c"abc\00"7@null = constant [1 x i8] zeroinitializer8 9declare i64 @strspn(ptr, ptr)10 11; Check strspn(s, "") -> 0.12 13define i64 @test_simplify1(ptr %str) {14; CHECK-LABEL: @test_simplify1(15 16  %ret = call i64 @strspn(ptr %str, ptr @null)17  ret i64 %ret18; CHECK-NEXT: ret i64 019}20 21; Check strspn("", s) -> 0.22 23define i64 @test_simplify2(ptr %pat) {24; CHECK-LABEL: @test_simplify2(25 26  %ret = call i64 @strspn(ptr @null, ptr %pat)27  ret i64 %ret28; CHECK-NEXT: ret i64 029}30 31; Check strspn(s1, s2), where s1 and s2 are constants.32 33define i64 @test_simplify3() {34; CHECK-LABEL: @test_simplify3(35 36  %ret = call i64 @strspn(ptr @abcba, ptr @abc)37  ret i64 %ret38; CHECK-NEXT: ret i64 539}40 41; Check cases that shouldn't be simplified.42 43define i64 @test_no_simplify1(ptr %str, ptr %pat) {44; CHECK-LABEL: @test_no_simplify1(45 46  %ret = call i64 @strspn(ptr %str, ptr %pat)47; CHECK-NEXT: %ret = call i64 @strspn(ptr %str, ptr %pat)48  ret i64 %ret49; CHECK-NEXT: ret i64 %ret50}51