Skip to content

Commit 1fd9a14

Browse files
committed
[msan] Add test for vector abs intrinsic
1 parent cb9cfa0 commit 1fd9a14

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -S -msan-check-access-address=0 -passes=msan 2>&1 | FileCheck %s
3+
; RUN: opt < %s -S -msan-check-access-address=0 -msan | FileCheck %s
4+
; RUN: opt < %s -S -msan-check-access-address=0 -msan-track-origins=2 -passes=msan 2>&1 | FileCheck %s --check-prefixes=CHECK,ORIGIN
5+
; RUN: opt < %s -S -msan-check-access-address=0 -msan-track-origins=2 -msan | FileCheck %s --check-prefixes=CHECK,ORIGIN
6+
7+
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
8+
target triple = "x86_64-unknown-linux-gnu"
9+
10+
define <4 x i64> @test_mm256_abs_epi8(<4 x i64> noundef %a) local_unnamed_addr #0 {
11+
; CHECK-LABEL: @test_mm256_abs_epi8(
12+
; CHECK-NEXT: entry:
13+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i64>, <4 x i64>* bitcast ([100 x i64]* @__msan_param_tls to <4 x i64>*), align 8
14+
; ORIGIN-NEXT: [[TMP1:%.*]] = load i32, i32* getelementptr inbounds ([200 x i32], [200 x i32]* @__msan_param_origin_tls, i32 0, i32 0), align 4
15+
; CHECK: [[TMP2:%.*]] = bitcast <4 x i64> [[TMP0]] to <32 x i8>
16+
; CHECK-NEXT: [[TMP3:%.*]] = bitcast <4 x i64> [[A:%.*]] to <32 x i8>
17+
; CHECK-NEXT: [[TMP4:%.*]] = bitcast <32 x i8> [[TMP2]] to i256
18+
; CHECK-NEXT: [[_MSCMP:%.*]] = icmp ne i256 [[TMP4]], 0
19+
; CHECK-NEXT: br i1 [[_MSCMP]], label [[TMP5:%.*]], label [[TMP6:%.*]], !prof !2
20+
; CHECK: call void @__msan_warning_with_origin_noreturn
21+
; CHECK: unreachable
22+
; CHECK: [[TMP7:%.*]] = tail call <32 x i8> @llvm.abs.v32i8(<32 x i8> [[TMP3]], i1 false)
23+
; CHECK-NEXT: [[TMP8:%.*]] = bitcast <32 x i8> [[TMP7]] to <4 x i64>
24+
; CHECK-NEXT: store <4 x i64> zeroinitializer, <4 x i64>* bitcast ([100 x i64]* @__msan_retval_tls to <4 x i64>*), align 8
25+
; ORIGIN-NEXT: store i32 0, i32* @__msan_retval_origin_tls, align 4
26+
; CHECK: ret <4 x i64> [[TMP8]]
27+
;
28+
entry:
29+
%0 = bitcast <4 x i64> %a to <32 x i8>
30+
%1 = tail call <32 x i8> @llvm.abs.v32i8(<32 x i8> %0, i1 false)
31+
%2 = bitcast <32 x i8> %1 to <4 x i64>
32+
ret <4 x i64> %2
33+
}
34+
35+
define <4 x i64> @test_mm256_abs_epi16(<4 x i64> %a) local_unnamed_addr #0 {
36+
; CHECK-LABEL: @test_mm256_abs_epi16(
37+
; CHECK-NEXT: entry:
38+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i64>, <4 x i64>* bitcast ([100 x i64]* @__msan_param_tls to <4 x i64>*), align 8
39+
; ORIGIN-NEXT: [[TMP1:%.*]] = load i32, i32* getelementptr inbounds ([200 x i32], [200 x i32]* @__msan_param_origin_tls, i32 0, i32 0), align 4
40+
; CHECK: [[TMP2:%.*]] = bitcast <4 x i64> [[TMP0]] to <16 x i16>
41+
; CHECK-NEXT: [[TMP3:%.*]] = bitcast <4 x i64> [[A:%.*]] to <16 x i16>
42+
; CHECK-NEXT: [[TMP4:%.*]] = bitcast <16 x i16> [[TMP2]] to i256
43+
; CHECK-NEXT: [[_MSCMP:%.*]] = icmp ne i256 [[TMP4]], 0
44+
; CHECK-NEXT: br i1 [[_MSCMP]], label [[TMP5:%.*]], label [[TMP6:%.*]], !prof !2
45+
; CHECK: call void @__msan_warning_with_origin_noreturn
46+
; CHECK: unreachable
47+
; CHECK: [[TMP7:%.*]] = tail call <16 x i16> @llvm.abs.v16i16(<16 x i16> [[TMP3]], i1 false)
48+
; CHECK-NEXT: [[TMP8:%.*]] = bitcast <16 x i16> [[TMP7]] to <4 x i64>
49+
; CHECK-NEXT: store <4 x i64> zeroinitializer, <4 x i64>* bitcast ([100 x i64]* @__msan_retval_tls to <4 x i64>*), align 8
50+
; ORIGIN-NEXT: store i32 0, i32* @__msan_retval_origin_tls, align 4
51+
; CHECK: ret <4 x i64> [[TMP8]]
52+
;
53+
entry:
54+
%0 = bitcast <4 x i64> %a to <16 x i16>
55+
%1 = tail call <16 x i16> @llvm.abs.v16i16(<16 x i16> %0, i1 false)
56+
%2 = bitcast <16 x i16> %1 to <4 x i64>
57+
ret <4 x i64> %2
58+
}
59+
60+
define <4 x i64> @test_mm256_abs_epi32(<4 x i64> %a) local_unnamed_addr #0 {
61+
; CHECK-LABEL: @test_mm256_abs_epi32(
62+
; CHECK-NEXT: entry:
63+
; CHECK-NEXT: [[TMP0:%.*]] = load <4 x i64>, <4 x i64>* bitcast ([100 x i64]* @__msan_param_tls to <4 x i64>*), align 8
64+
; ORIGIN-NEXT: [[TMP1:%.*]] = load i32, i32* getelementptr inbounds ([200 x i32], [200 x i32]* @__msan_param_origin_tls, i32 0, i32 0), align 4
65+
; CHECK: [[TMP2:%.*]] = bitcast <4 x i64> [[TMP0]] to <8 x i32>
66+
; CHECK-NEXT: [[TMP3:%.*]] = bitcast <4 x i64> [[A:%.*]] to <8 x i32>
67+
; CHECK-NEXT: [[TMP4:%.*]] = bitcast <8 x i32> [[TMP2]] to i256
68+
; CHECK-NEXT: [[_MSCMP:%.*]] = icmp ne i256 [[TMP4]], 0
69+
; CHECK-NEXT: br i1 [[_MSCMP]], label [[TMP5:%.*]], label [[TMP6:%.*]], !prof !2
70+
; CHECK: call void @__msan_warning_with_origin_noreturn
71+
; CHECK: unreachable
72+
; CHECK: [[TMP7:%.*]] = tail call <8 x i32> @llvm.abs.v8i32(<8 x i32> [[TMP3]], i1 false)
73+
; CHECK-NEXT: [[TMP8:%.*]] = bitcast <8 x i32> [[TMP7]] to <4 x i64>
74+
; CHECK-NEXT: store <4 x i64> zeroinitializer, <4 x i64>* bitcast ([100 x i64]* @__msan_retval_tls to <4 x i64>*), align 8
75+
; ORIGIN-NEXT: store i32 0, i32* @__msan_retval_origin_tls, align 4
76+
; CHECK: ret <4 x i64> [[TMP8]]
77+
;
78+
entry:
79+
%0 = bitcast <4 x i64> %a to <8 x i32>
80+
%1 = tail call <8 x i32> @llvm.abs.v8i32(<8 x i32> %0, i1 false)
81+
%2 = bitcast <8 x i32> %1 to <4 x i64>
82+
ret <4 x i64> %2
83+
}
84+
85+
declare <32 x i8> @llvm.abs.v32i8(<32 x i8>, i1 immarg) #1
86+
declare <16 x i16> @llvm.abs.v16i16(<16 x i16>, i1 immarg) #1
87+
declare <8 x i32> @llvm.abs.v8i32(<8 x i32>, i1 immarg) #1
88+
89+
attributes #0 = { nounwind readnone sanitize_memory }
90+
attributes #1 = { nounwind readnone speculatable willreturn }
91+
92+
!llvm.module.flags = !{!0}
93+
!llvm.ident = !{!1}
94+
95+
!0 = !{i32 1, !"wchar_size", i32 4}
96+
!1 = !{!"clang version 12.0.0"}

0 commit comments

Comments
 (0)