Skip to content

Commit 497e2e8

Browse files
authored
[NFC][VectorCombine] Add negative sanitizer tests (#100832)
They are already work as expected.
1 parent 10bb296 commit 497e2e8

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

llvm/test/Transforms/VectorCombine/X86/load-inseltpoison.ll

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,58 @@ define <8 x i16> @gep1_load_v2i16_extract_insert_v8i16(ptr align 1 dereferenceab
626626
ret <8 x i16> %r
627627
}
628628

629+
; Negative sanitizer tests.
630+
631+
define <4 x i32> @load_i32_insert_v4i32_asan(ptr align 16 dereferenceable(16) %p) nofree nosync sanitize_address {
632+
; CHECK-LABEL: @load_i32_insert_v4i32_asan(
633+
; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[P:%.*]], align 4
634+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> poison, i32 [[S]], i32 0
635+
; CHECK-NEXT: ret <4 x i32> [[R]]
636+
;
637+
%s = load i32, ptr %p, align 4
638+
%r = insertelement <4 x i32> poison, i32 %s, i32 0
639+
ret <4 x i32> %r
640+
}
641+
642+
define <4 x float> @load_v2f32_extract_insert_v4f32_hwasan(ptr align 16 dereferenceable(16) %p) nofree nosync sanitize_hwaddress {
643+
; CHECK-LABEL: @load_v2f32_extract_insert_v4f32_hwasan(
644+
; CHECK-NEXT: [[L:%.*]] = load <2 x float>, ptr [[P:%.*]], align 4
645+
; CHECK-NEXT: [[S:%.*]] = extractelement <2 x float> [[L]], i32 0
646+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> poison, float [[S]], i32 0
647+
; CHECK-NEXT: ret <4 x float> [[R]]
648+
;
649+
%l = load <2 x float>, ptr %p, align 4
650+
%s = extractelement <2 x float> %l, i32 0
651+
%r = insertelement <4 x float> poison, float %s, i32 0
652+
ret <4 x float> %r
653+
}
654+
655+
define <4 x float> @load_v2f32_extract_insert_v4f32_tsan(ptr align 16 dereferenceable(16) %p) nofree nosync sanitize_thread {
656+
; CHECK-LABEL: @load_v2f32_extract_insert_v4f32_tsan(
657+
; CHECK-NEXT: [[L:%.*]] = load <2 x float>, ptr [[P:%.*]], align 4
658+
; CHECK-NEXT: [[S:%.*]] = extractelement <2 x float> [[L]], i32 0
659+
; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> poison, float [[S]], i32 0
660+
; CHECK-NEXT: ret <4 x float> [[R]]
661+
;
662+
%l = load <2 x float>, ptr %p, align 4
663+
%s = extractelement <2 x float> %l, i32 0
664+
%r = insertelement <4 x float> poison, float %s, i32 0
665+
ret <4 x float> %r
666+
}
667+
668+
; Double negative msan tests, it's OK with the optimization.
669+
670+
define <2 x float> @load_f32_insert_v2f32_msan(ptr align 16 dereferenceable(16) %p) nofree nosync sanitize_memory {
671+
; CHECK-LABEL: @load_f32_insert_v2f32_msan(
672+
; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16
673+
; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <2 x i32> <i32 0, i32 poison>
674+
; CHECK-NEXT: ret <2 x float> [[R]]
675+
;
676+
%s = load float, ptr %p, align 4
677+
%r = insertelement <2 x float> poison, float %s, i32 0
678+
ret <2 x float> %r
679+
}
680+
629681
; PR30986 - split vector loads for scalarized operations
630682
define <2 x i64> @PR30986(ptr %0) {
631683
; CHECK-LABEL: @PR30986(

llvm/test/Transforms/VectorCombine/X86/load-widening.ll

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,83 @@ define <4 x i32> @load_v2i32_v4i32_addrspacecast(ptr addrspace(5) align 16 deref
382382
%s = shufflevector <2 x i32> %l, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
383383
ret <4 x i32> %s
384384
}
385+
386+
; Negative-negative tests with msan, which should be OK with widening.
387+
388+
define <4 x float> @load_v1f32_v4f32_msan(ptr dereferenceable(16) %p) sanitize_memory {
389+
; CHECK-LABEL: @load_v1f32_v4f32_msan(
390+
; CHECK-NEXT: [[S:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16
391+
; CHECK-NEXT: ret <4 x float> [[S]]
392+
;
393+
%l = load <1 x float>, ptr %p, align 16
394+
%s = shufflevector <1 x float> %l, <1 x float> poison, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
395+
ret <4 x float> %s
396+
}
397+
398+
; Negative tests with sanitizers.
399+
400+
define <4 x float> @load_v1f32_v4f32_asan(ptr dereferenceable(16) %p) sanitize_address {
401+
; CHECK-LABEL: @load_v1f32_v4f32_asan(
402+
; CHECK-NEXT: [[L:%.*]] = load <1 x float>, ptr [[P:%.*]], align 16
403+
; CHECK-NEXT: [[S:%.*]] = shufflevector <1 x float> [[L]], <1 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>
404+
; CHECK-NEXT: ret <4 x float> [[S]]
405+
;
406+
%l = load <1 x float>, ptr %p, align 16
407+
%s = shufflevector <1 x float> %l, <1 x float> poison, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
408+
ret <4 x float> %s
409+
}
410+
411+
define <4 x float> @load_v2f32_v4f32_hwasan(ptr align 16 dereferenceable(16) %p) sanitize_hwaddress {
412+
; CHECK-LABEL: @load_v2f32_v4f32_hwasan(
413+
; CHECK-NEXT: [[L:%.*]] = load <2 x float>, ptr [[P:%.*]], align 1
414+
; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x float> [[L]], <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 poison, i32 poison>
415+
; CHECK-NEXT: ret <4 x float> [[S]]
416+
;
417+
%l = load <2 x float>, ptr %p, align 1
418+
%s = shufflevector <2 x float> %l, <2 x float> poison, <4 x i32> <i32 0, i32 1, i32 undef, i32 undef>
419+
ret <4 x float> %s
420+
}
421+
422+
define <4 x float> @load_v3f32_v4f32_tsan(ptr dereferenceable(16) %p) sanitize_thread {
423+
; CHECK-LABEL: @load_v3f32_v4f32_tsan(
424+
; CHECK-NEXT: [[L:%.*]] = load <3 x float>, ptr [[P:%.*]], align 1
425+
; CHECK-NEXT: [[S:%.*]] = shufflevector <3 x float> [[L]], <3 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 poison>
426+
; CHECK-NEXT: ret <4 x float> [[S]]
427+
;
428+
%l = load <3 x float>, ptr %p, align 1
429+
%s = shufflevector <3 x float> %l, <3 x float> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 undef>
430+
ret <4 x float> %s
431+
}
432+
433+
define <8 x float> @load_v2f32_v8f32_hwasan(ptr dereferenceable(32) %p) sanitize_hwaddress {
434+
; CHECK-LABEL: @load_v2f32_v8f32_hwasan(
435+
; CHECK-NEXT: [[L:%.*]] = load <2 x float>, ptr [[P:%.*]], align 1
436+
; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x float> [[L]], <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
437+
; CHECK-NEXT: ret <8 x float> [[S]]
438+
;
439+
%l = load <2 x float>, ptr %p, align 1
440+
%s = shufflevector <2 x float> %l, <2 x float> poison, <8 x i32> <i32 0, i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef>
441+
ret <8 x float> %s
442+
}
443+
444+
define <4 x i32> @load_v2i32_v4i32_asan(ptr dereferenceable(16) %p) sanitize_address {
445+
; CHECK-LABEL: @load_v2i32_v4i32_asan(
446+
; CHECK-NEXT: [[L:%.*]] = load <2 x i32>, ptr [[P:%.*]], align 1
447+
; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x i32> [[L]], <2 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison>
448+
; CHECK-NEXT: ret <4 x i32> [[S]]
449+
;
450+
%l = load <2 x i32>, ptr %p, align 1
451+
%s = shufflevector <2 x i32> %l, <2 x i32> poison, <4 x i32> <i32 0, i32 undef, i32 undef, i32 undef>
452+
ret <4 x i32> %s
453+
}
454+
455+
define <4 x i32> @load_v2i32_v4i32_non_canonical_mask_commute_hwasan(ptr dereferenceable(16) %p) sanitize_hwaddress {
456+
; CHECK-LABEL: @load_v2i32_v4i32_non_canonical_mask_commute_hwasan(
457+
; CHECK-NEXT: [[L:%.*]] = load <2 x i32>, ptr [[P:%.*]], align 1
458+
; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x i32> poison, <2 x i32> [[L]], <4 x i32> <i32 2, i32 3, i32 poison, i32 poison>
459+
; CHECK-NEXT: ret <4 x i32> [[S]]
460+
;
461+
%l = load <2 x i32>, ptr %p, align 1
462+
%s = shufflevector <2 x i32> poison, <2 x i32> %l, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
463+
ret <4 x i32> %s
464+
}

0 commit comments

Comments
 (0)