Skip to content

Instantly share code, notes, and snippets.

@nikic
Created May 14, 2018 20:28
Show Gist options
  • Save nikic/d55cb75635a52a29790248b6bcd24be8 to your computer and use it in GitHub Desktop.
Save nikic/d55cb75635a52a29790248b6bcd24be8 to your computer and use it in GitHub Desktop.
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.__loadu_si128 = type { <2 x i64> }
define i32 @validate_ascii(i8*, i64, i8*, i64*) #4 {
%5 = icmp ule i64 16, %1
br i1 %5, label %6, label %30
%7 = sub i64 %1, 16
br label %8
%.0 = phi i64 [ 0, %6 ], [ %25, %28 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %.0
%10 = call <2 x i64> @load16_unaligned(i8* %9)
%11 = call i32 @mask_ascii(<2 x i64> %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %24
%14 = icmp ne i32 %11, 0
br i1 %14, label %15, label %17
%16 = call i32 @llvm.cttz.i32(i32 %11, i1 true) #7
br label %18
br label %18
%19 = phi i32 [ %16, %15 ], [ 32, %17 ]
%20 = zext i32 %19 to i64
%21 = add i64 %.0, %20
%22 = getelementptr inbounds i8, i8* %0, i64 %21
%23 = load i8, i8* %22, align 1
store i8 %23, i8* %2, align 1
store i64 %21, i64* %3, align 8
br label %42
%25 = add i64 %.0, 16
%26 = icmp ugt i64 %25, %7
br i1 %26, label %27, label %28
br label %29
br label %8, !llvm.loop !3
br label %30
%.1 = phi i64 [ %25, %29 ], [ 0, %4 ]
br label %31
%.2 = phi i64 [ %.1, %30 ], [ %40, %39 ]
%32 = icmp ult i64 %.2, %1
br i1 %32, label %33, label %41
%34 = getelementptr inbounds i8, i8* %0, i64 %.2
%35 = load i8, i8* %34, align 1
%36 = sext i8 %35 to i32
%37 = icmp sgt i32 %36, 127
br i1 %37, label %38, label %39
store i8 %35, i8* %2, align 1
store i64 %.2, i64* %3, align 8
br label %42
%40 = add i64 %.2, 1
br label %31
br label %42
%.01 = phi i32 [ 1, %18 ], [ 1, %38 ], [ 0, %41 ]
ret i32 %.01
}
define internal <2 x i64> @load16_unaligned(i8*) #4 {
%2 = bitcast i8* %0 to <2 x i64>*
%3 = bitcast <2 x i64>* %2 to %struct.__loadu_si128*
%4 = getelementptr inbounds %struct.__loadu_si128, %struct.__loadu_si128* %3, i32 0, i32 0
%5 = load <2 x i64>, <2 x i64>* %4, align 1
ret <2 x i64> %5
}
define internal i32 @mask_ascii(<2 x i64>) #4 {
%2 = bitcast <2 x i64> %0 to <16 x i8>
%3 = call i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8> %2) #7
ret i32 %3
}
declare i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8>) #5
declare i32 @llvm.cttz.i32(i32, i1) #6
attributes #0 = { noinline norecurse uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { noinline }
attributes #4 = { uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #5 = { nounwind readnone }
attributes #6 = { nounwind readnone speculatable }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 7.0.0 (trunk 332192)"}
!2 = !{i32 1340}
!3 = distinct !{!3, !4}
!4 = !{!"llvm.loop.unroll.disable"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment