File: sadd.with.overflow.ll

package info (click to toggle)
spirv-llvm-translator-15 15.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,028 kB
  • sloc: cpp: 43,715; lisp: 3,497; sh: 153; python: 43; makefile: 26
file content (88 lines) | stat: -rw-r--r-- 3,353 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
; The test is generated by Clang from the following source:
;
; void foo32(int a, int b, int *c) {
;   *c = a + b;
; }
;
; void foo64(long a, long b, long *c) {
;   *c = a + b;
; }
;
; With the following options:
; -emit-llvm -fno-discard-value-names -O2 -g0 -ftrapv -target spir

; RUN: llvm-as < %s -o %t.bc
; RUN: llvm-spirv -s %t.bc -o - | llvm-dis -o - | FileCheck %s

; CHECK: call { i32, i1 } @llvm_sadd_with_overflow_i32
; CHECK-NOT: call { i32, i1 } @llvm.sadd.with.overflow.i32

; CHECK: call { i64, i1 } @llvm_sadd_with_overflow_i64
; CHECK-NOT: call { i64, i1 } @llvm.sadd.with.overflow.i64

; CHECK-NOT: call { i16, i1 } @llvm_sadd_with_overflow_i16


target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir"

; Function Attrs: nounwind
define dso_local spir_func void @foo32(i32 %a, i32 %b, i32* nocapture %c) local_unnamed_addr #0 {
entry:
  %0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b), !nosanitize !2
  %1 = extractvalue { i32, i1 } %0, 1, !nosanitize !2
  br i1 %1, label %trap, label %cont, !nosanitize !2

trap:                                             ; preds = %entry
  tail call void @llvm.trap() #3, !nosanitize !2
  unreachable, !nosanitize !2

cont:                                             ; preds = %entry
  %2 = extractvalue { i32, i1 } %0, 0, !nosanitize !2
  store i32 %2, i32* %c, align 4, !tbaa !3
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1

; Function Attrs: cold noreturn nounwind
declare void @llvm.trap() #2

; Function Attrs: nounwind
define dso_local spir_func void @foo64(i64 %a, i64 %b, i64* nocapture %c) local_unnamed_addr #0 {
entry:
  %0 = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b), !nosanitize !2
  %1 = extractvalue { i64, i1 } %0, 1, !nosanitize !2
  br i1 %1, label %trap, label %cont, !nosanitize !2

trap:                                             ; preds = %entry
  tail call void @llvm.trap() #3, !nosanitize !2
  unreachable, !nosanitize !2

cont:                                             ; preds = %entry
  %2 = extractvalue { i64, i1 } %0, 0, !nosanitize !2
  store i64 %2, i64* %c, align 8, !tbaa !7
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #1

attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind readnone speculatable willreturn }
attributes #2 = { cold noreturn nounwind }
attributes #3 = { noreturn nounwind }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 576fa5a50c8509977835031d190f8906e1dbb075)"}
!2 = !{}
!3 = !{!4, !4, i64 0}
!4 = !{!"int", !5, i64 0}
!5 = !{!"omnipotent char", !6, i64 0}
!6 = !{!"Simple C/C++ TBAA"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long", !5, i64 0}