value-bug.ll 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. ; RUN: opt -slp-vectorizer < %s -S -mtriple="x86_64-grtev3-linux-gnu" -mcpu=corei7-avx | FileCheck %s
  2. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-grtev3-linux-gnu"
  4. ; We used to crash on this example because we were building a constant
  5. ; expression during vectorization and the vectorizer expects instructions
  6. ; as elements of the vectorized tree.
  7. ; CHECK-LABEL: @test
  8. ; PR19621
  9. define void @test() {
  10. bb279:
  11. br label %bb283
  12. bb283:
  13. %Av.sroa.8.0 = phi float [ undef, %bb279 ], [ %tmp315, %exit ]
  14. %Av.sroa.5.0 = phi float [ undef, %bb279 ], [ %tmp319, %exit ]
  15. %Av.sroa.3.0 = phi float [ undef, %bb279 ], [ %tmp307, %exit ]
  16. %Av.sroa.0.0 = phi float [ undef, %bb279 ], [ %tmp317, %exit ]
  17. br label %bb284
  18. bb284:
  19. %tmp7.i = fpext float %Av.sroa.3.0 to double
  20. %tmp8.i = fsub double %tmp7.i, undef
  21. %tmp9.i = fsub double %tmp8.i, undef
  22. %tmp17.i = fpext float %Av.sroa.8.0 to double
  23. %tmp19.i = fsub double %tmp17.i, undef
  24. %tmp20.i = fsub double %tmp19.i, undef
  25. br label %bb21.i
  26. bb21.i:
  27. br i1 undef, label %bb22.i, label %exit
  28. bb22.i:
  29. %tmp24.i = fadd double undef, %tmp9.i
  30. %tmp26.i = fadd double undef, %tmp20.i
  31. br label %bb32.i
  32. bb32.i:
  33. %xs.0.i = phi double [ %tmp24.i, %bb22.i ], [ 0.000000e+00, %bb32.i ]
  34. %ys.0.i = phi double [ %tmp26.i, %bb22.i ], [ 0.000000e+00, %bb32.i ]
  35. br i1 undef, label %bb32.i, label %bb21.i
  36. exit:
  37. %tmp303 = fpext float %Av.sroa.0.0 to double
  38. %tmp304 = fmul double %tmp303, undef
  39. %tmp305 = fadd double undef, %tmp304
  40. %tmp306 = fadd double %tmp305, undef
  41. %tmp307 = fptrunc double %tmp306 to float
  42. %tmp311 = fpext float %Av.sroa.5.0 to double
  43. %tmp312 = fmul double %tmp311, 0.000000e+00
  44. %tmp313 = fadd double undef, %tmp312
  45. %tmp314 = fadd double %tmp313, undef
  46. %tmp315 = fptrunc double %tmp314 to float
  47. %tmp317 = fptrunc double undef to float
  48. %tmp319 = fptrunc double undef to float
  49. br label %bb283
  50. }
  51. ; Make sure that we probably handle constant folded vectorized trees. The
  52. ; vectorizer starts at the type (%t2, %t3) and wil constant fold the tree.
  53. ; The code that handles insertelement instructions must handle this.
  54. define <4 x double> @constant_folding() {
  55. entry:
  56. %t0 = fadd double 1.000000e+00 , 0.000000e+00
  57. %t1 = fadd double 1.000000e+00 , 1.000000e+00
  58. %t2 = fmul double %t0, 1.000000e+00
  59. %i1 = insertelement <4 x double> undef, double %t2, i32 1
  60. %t3 = fmul double %t1, 1.000000e+00
  61. %i2 = insertelement <4 x double> %i1, double %t3, i32 0
  62. ret <4 x double> %i2
  63. }
  64. ; CHECK-LABEL: @constant_folding
  65. ; CHECK: %[[V0:.+]] = extractelement <2 x double> <double 1.000000e+00, double 2.000000e+00>, i32 0
  66. ; CHECK: %[[V1:.+]] = insertelement <4 x double> undef, double %[[V0]], i32 1
  67. ; CHECK: %[[V2:.+]] = extractelement <2 x double> <double 1.000000e+00, double 2.000000e+00>, i32 1
  68. ; CHECK: %[[V3:.+]] = insertelement <4 x double> %[[V1]], double %[[V2]], i32 0
  69. ; CHECK: ret <4 x double> %[[V3]]