commute.ll 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ; RUN: opt -S -slp-vectorizer %s | FileCheck %s
  2. target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
  3. target triple = "aarch64--linux-gnu"
  4. %structA = type { [2 x float] }
  5. define void @test1(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
  6. ; CHECK-LABEL: test1
  7. ; CHECK: %arrayidx4 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 0
  8. ; CHECK: %arrayidx9 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 1
  9. ; CHECK: %3 = bitcast float* %arrayidx4 to <2 x float>*
  10. ; CHECK: %4 = load <2 x float>, <2 x float>* %3, align 4
  11. ; CHECK: %5 = fsub fast <2 x float> %2, %4
  12. ; CHECK: %6 = fmul fast <2 x float> %5, %5
  13. ; CHECK: %7 = extractelement <2 x float> %6, i32 0
  14. ; CHECK: %8 = extractelement <2 x float> %6, i32 1
  15. ; CHECK: %add = fadd fast float %7, %8
  16. ; CHECK: %cmp = fcmp oeq float %add, 0.000000e+00
  17. entry:
  18. br label %for.body3.lr.ph
  19. for.body3.lr.ph:
  20. %conv5 = sitofp i32 %ymin to float
  21. %conv = sitofp i32 %xmin to float
  22. %arrayidx4 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 0
  23. %0 = load float, float* %arrayidx4, align 4
  24. %sub = fsub fast float %conv, %0
  25. %arrayidx9 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 1
  26. %1 = load float, float* %arrayidx9, align 4
  27. %sub10 = fsub fast float %conv5, %1
  28. %mul11 = fmul fast float %sub, %sub
  29. %mul12 = fmul fast float %sub10, %sub10
  30. %add = fadd fast float %mul11, %mul12
  31. %cmp = fcmp oeq float %add, 0.000000e+00
  32. br i1 %cmp, label %for.body3.lr.ph, label %for.end27
  33. for.end27:
  34. ret void
  35. }
  36. define void @test2(%structA* nocapture readonly %J, i32 %xmin, i32 %ymin) {
  37. ; CHECK-LABEL: test2
  38. ; CHECK: %arrayidx4 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 0
  39. ; CHECK: %arrayidx9 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 1
  40. ; CHECK: %3 = bitcast float* %arrayidx4 to <2 x float>*
  41. ; CHECK: %4 = load <2 x float>, <2 x float>* %3, align 4
  42. ; CHECK: %5 = fsub fast <2 x float> %2, %4
  43. ; CHECK: %6 = fmul fast <2 x float> %5, %5
  44. ; CHECK: %7 = extractelement <2 x float> %6, i32 0
  45. ; CHECK: %8 = extractelement <2 x float> %6, i32 1
  46. ; CHECK: %add = fadd fast float %8, %7
  47. ; CHECK: %cmp = fcmp oeq float %add, 0.000000e+00
  48. entry:
  49. br label %for.body3.lr.ph
  50. for.body3.lr.ph:
  51. %conv5 = sitofp i32 %ymin to float
  52. %conv = sitofp i32 %xmin to float
  53. %arrayidx4 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 0
  54. %0 = load float, float* %arrayidx4, align 4
  55. %sub = fsub fast float %conv, %0
  56. %arrayidx9 = getelementptr inbounds %structA, %structA* %J, i64 0, i32 0, i64 1
  57. %1 = load float, float* %arrayidx9, align 4
  58. %sub10 = fsub fast float %conv5, %1
  59. %mul11 = fmul fast float %sub, %sub
  60. %mul12 = fmul fast float %sub10, %sub10
  61. %add = fadd fast float %mul12, %mul11 ;;;<---- Operands commuted!!
  62. %cmp = fcmp oeq float %add, 0.000000e+00
  63. br i1 %cmp, label %for.body3.lr.ph, label %for.end27
  64. for.end27:
  65. ret void
  66. }