machine-sink.ll 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
  2. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
  3. @scalar1 = internal addrspace(3) global float 0.000000e+00, align 4
  4. @scalar2 = internal addrspace(3) global float 0.000000e+00, align 4
  5. ; We shouldn't sink mul.rn.f32 to BB %merge because BB %merge post-dominates
  6. ; BB %entry. Over-sinking created more register pressure on this example. The
  7. ; backend would sink the fmuls to BB %merge, but not the loads for being
  8. ; conservative on sinking memory accesses. As a result, the loads and
  9. ; the two fmuls would be separated to two basic blocks, causing two
  10. ; cross-BB live ranges.
  11. define float @post_dominate(float %x, i1 %cond) {
  12. ; CHECK-LABEL: post_dominate(
  13. entry:
  14. %0 = load float, float* addrspacecast (float addrspace(3)* @scalar1 to float*), align 4
  15. %1 = load float, float* addrspacecast (float addrspace(3)* @scalar2 to float*), align 4
  16. ; CHECK: ld.shared.f32
  17. ; CHECK: ld.shared.f32
  18. %2 = fmul float %0, %0
  19. %3 = fmul float %1, %2
  20. ; CHECK-NOT: bra
  21. ; CHECK: mul.rn.f32
  22. ; CHECK: mul.rn.f32
  23. br i1 %cond, label %then, label %merge
  24. then:
  25. %z = fadd float %x, %x
  26. br label %then2
  27. then2:
  28. %z2 = fadd float %z, %z
  29. br label %merge
  30. merge:
  31. %y = phi float [ 0.0, %entry ], [ %z2, %then2 ]
  32. %w = fadd float %y, %3
  33. ret float %w
  34. }