vector_shift.ll 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
  2. ; Test instrumentation of vector shift instructions.
  3. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  4. target triple = "x86_64-unknown-linux-gnu"
  5. declare x86_mmx @llvm.x86.mmx.psll.d(x86_mmx, x86_mmx)
  6. declare <8 x i32> @llvm.x86.avx2.psllv.d.256(<8 x i32>, <8 x i32>)
  7. declare <4 x i32> @llvm.x86.avx2.psllv.d(<4 x i32>, <4 x i32>)
  8. declare <8 x i16> @llvm.x86.sse2.psrl.w(<8 x i16>, <8 x i16>)
  9. declare <8 x i16> @llvm.x86.sse2.pslli.w(<8 x i16>, i32)
  10. declare <2 x i64> @llvm.x86.sse2.psll.dq(<2 x i64>, i32)
  11. declare <2 x i64> @llvm.x86.sse2.psll.dq.bs(<2 x i64>, i32)
  12. define i64 @test_mmx(i64 %x.coerce, i64 %y.coerce) sanitize_memory {
  13. entry:
  14. %0 = bitcast i64 %x.coerce to <2 x i32>
  15. %1 = bitcast <2 x i32> %0 to x86_mmx
  16. %2 = bitcast i64 %y.coerce to x86_mmx
  17. %3 = tail call x86_mmx @llvm.x86.mmx.psll.d(x86_mmx %1, x86_mmx %2)
  18. %4 = bitcast x86_mmx %3 to <2 x i32>
  19. %5 = bitcast <2 x i32> %4 to <1 x i64>
  20. %6 = extractelement <1 x i64> %5, i32 0
  21. ret i64 %6
  22. }
  23. ; CHECK: @test_mmx
  24. ; CHECK: = icmp ne i64 {{.*}}, 0
  25. ; CHECK: [[C:%.*]] = sext i1 {{.*}} to i64
  26. ; CHECK: [[A:%.*]] = call x86_mmx @llvm.x86.mmx.psll.d(
  27. ; CHECK: [[B:%.*]] = bitcast x86_mmx {{.*}}[[A]] to i64
  28. ; CHECK: = or i64 {{.*}}[[B]], {{.*}}[[C]]
  29. ; CHECK: call x86_mmx @llvm.x86.mmx.psll.d(
  30. ; CHECK: ret i64
  31. define <8 x i16> @test_sse2_scalar(<8 x i16> %x, i32 %y) sanitize_memory {
  32. entry:
  33. %0 = tail call <8 x i16> @llvm.x86.sse2.pslli.w(<8 x i16> %x, i32 %y)
  34. ret <8 x i16> %0
  35. }
  36. ; CHECK: @test_sse2_scalar
  37. ; CHECK: = icmp ne i32 {{.*}}, 0
  38. ; CHECK: = sext i1 {{.*}} to i128
  39. ; CHECK: = bitcast i128 {{.*}} to <8 x i16>
  40. ; CHECK: = call <8 x i16> @llvm.x86.sse2.pslli.w(
  41. ; CHECK: = or <8 x i16>
  42. ; CHECK: call <8 x i16> @llvm.x86.sse2.pslli.w(
  43. ; CHECK: ret <8 x i16>
  44. define <8 x i16> @test_sse2(<8 x i16> %x, <8 x i16> %y) sanitize_memory {
  45. entry:
  46. %0 = tail call <8 x i16> @llvm.x86.sse2.psrl.w(<8 x i16> %x, <8 x i16> %y)
  47. ret <8 x i16> %0
  48. }
  49. ; CHECK: @test_sse2
  50. ; CHECK: = bitcast <8 x i16> {{.*}} to i128
  51. ; CHECK: = trunc i128 {{.*}} to i64
  52. ; CHECK: = icmp ne i64 {{.*}}, 0
  53. ; CHECK: = sext i1 {{.*}} to i128
  54. ; CHECK: = bitcast i128 {{.*}} to <8 x i16>
  55. ; CHECK: = call <8 x i16> @llvm.x86.sse2.psrl.w(
  56. ; CHECK: = or <8 x i16>
  57. ; CHECK: call <8 x i16> @llvm.x86.sse2.psrl.w(
  58. ; CHECK: ret <8 x i16>
  59. ; Test variable shift (i.e. vector by vector).
  60. define <4 x i32> @test_avx2(<4 x i32> %x, <4 x i32> %y) sanitize_memory {
  61. entry:
  62. %0 = tail call <4 x i32> @llvm.x86.avx2.psllv.d(<4 x i32> %x, <4 x i32> %y)
  63. ret <4 x i32> %0
  64. }
  65. ; CHECK: @test_avx2
  66. ; CHECK: = icmp ne <4 x i32> {{.*}}, zeroinitializer
  67. ; CHECK: = sext <4 x i1> {{.*}} to <4 x i32>
  68. ; CHECK: = call <4 x i32> @llvm.x86.avx2.psllv.d(
  69. ; CHECK: = or <4 x i32>
  70. ; CHECK: = tail call <4 x i32> @llvm.x86.avx2.psllv.d(
  71. ; CHECK: ret <4 x i32>
  72. define <8 x i32> @test_avx2_256(<8 x i32> %x, <8 x i32> %y) sanitize_memory {
  73. entry:
  74. %0 = tail call <8 x i32> @llvm.x86.avx2.psllv.d.256(<8 x i32> %x, <8 x i32> %y)
  75. ret <8 x i32> %0
  76. }
  77. ; CHECK: @test_avx2_256
  78. ; CHECK: = icmp ne <8 x i32> {{.*}}, zeroinitializer
  79. ; CHECK: = sext <8 x i1> {{.*}} to <8 x i32>
  80. ; CHECK: = call <8 x i32> @llvm.x86.avx2.psllv.d.256(
  81. ; CHECK: = or <8 x i32>
  82. ; CHECK: = tail call <8 x i32> @llvm.x86.avx2.psllv.d.256(
  83. ; CHECK: ret <8 x i32>