currentLimitation.ll 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ; RUN: opt < %s -basicaa -loop-interchange -S | FileCheck %s
  2. ;; These are test that fail to interchange due to current limitation. This will go off once we extend the loop interchange pass.
  3. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  4. target triple = "x86_64-unknown-linux-gnu"
  5. @A = common global [100 x [100 x i32]] zeroinitializer
  6. @B = common global [100 x [100 x [100 x i32]]] zeroinitializer
  7. ;;--------------------------------------Test case 01------------------------------------
  8. ;; [FIXME] This loop though valid is currently not interchanged due to the limitation that we cannot split the inner loop latch due to multiple use of inner induction
  9. ;; variable.(used to increment the loop counter and to access A[j+1][i+1]
  10. ;; for(int i=0;i<N-1;i++)
  11. ;; for(int j=1;j<N-1;j++)
  12. ;; A[j+1][i+1] = A[j+1][i+1] + k;
  13. define void @interchange_01(i32 %k, i32 %N) {
  14. entry:
  15. %sub = add nsw i32 %N, -1
  16. %cmp26 = icmp sgt i32 %N, 1
  17. br i1 %cmp26, label %for.cond1.preheader.lr.ph, label %for.end17
  18. for.cond1.preheader.lr.ph:
  19. %cmp324 = icmp sgt i32 %sub, 1
  20. %0 = add i32 %N, -2
  21. %1 = sext i32 %sub to i64
  22. br label %for.cond1.preheader
  23. for.cond.loopexit:
  24. %cmp = icmp slt i64 %indvars.iv.next29, %1
  25. br i1 %cmp, label %for.cond1.preheader, label %for.end17
  26. for.cond1.preheader:
  27. %indvars.iv28 = phi i64 [ 0, %for.cond1.preheader.lr.ph ], [ %indvars.iv.next29, %for.cond.loopexit ]
  28. %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  29. br i1 %cmp324, label %for.body4, label %for.cond.loopexit
  30. for.body4:
  31. %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 1, %for.cond1.preheader ]
  32. %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  33. %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next, i64 %indvars.iv.next29
  34. %2 = load i32, i32* %arrayidx7
  35. %add8 = add nsw i32 %2, %k
  36. store i32 %add8, i32* %arrayidx7
  37. %lftr.wideiv = trunc i64 %indvars.iv to i32
  38. %exitcond = icmp eq i32 %lftr.wideiv, %0
  39. br i1 %exitcond, label %for.cond.loopexit, label %for.body4
  40. for.end17:
  41. ret void
  42. }
  43. ;; Inner loop not split so it is not interchanged.
  44. ; CHECK-LABEL: @interchange_01
  45. ; CHECK: for.body4:
  46. ; CHECK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 1, %for.body4.preheader ]
  47. ; CHECK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  48. ; CHECK-NEXT: %arrayidx7 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* @A, i64 0, i64 %indvars.iv.next, i64 %indvars.iv.next29