2005-06-30-ReadBeforeWrite.ll 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ; RUN: opt < %s -mem2reg -instcombine -S | grep store
  2. ; PR590
  3. define void @zero(i8* %p, i32 %n) {
  4. entry:
  5. %p_addr = alloca i8* ; <i8**> [#uses=2]
  6. %n_addr = alloca i32 ; <i32*> [#uses=2]
  7. %i = alloca i32 ; <i32*> [#uses=6]
  8. %out = alloca i32 ; <i32*> [#uses=2]
  9. %undef = alloca i32 ; <i32*> [#uses=2]
  10. store i8* %p, i8** %p_addr
  11. store i32 %n, i32* %n_addr
  12. store i32 0, i32* %i
  13. br label %loopentry
  14. loopentry: ; preds = %endif, %entry
  15. %tmp.0 = load i32, i32* %n_addr ; <i32> [#uses=1]
  16. %tmp.1 = add i32 %tmp.0, 1 ; <i32> [#uses=1]
  17. %tmp.2 = load i32, i32* %i ; <i32> [#uses=1]
  18. %tmp.3 = icmp sgt i32 %tmp.1, %tmp.2 ; <i1> [#uses=2]
  19. %tmp.4 = zext i1 %tmp.3 to i32 ; <i32> [#uses=0]
  20. br i1 %tmp.3, label %no_exit, label %return
  21. no_exit: ; preds = %loopentry
  22. %tmp.5 = load i32, i32* %undef ; <i32> [#uses=1]
  23. store i32 %tmp.5, i32* %out
  24. store i32 0, i32* %undef
  25. %tmp.6 = load i32, i32* %i ; <i32> [#uses=1]
  26. %tmp.7 = icmp sgt i32 %tmp.6, 0 ; <i1> [#uses=2]
  27. %tmp.8 = zext i1 %tmp.7 to i32 ; <i32> [#uses=0]
  28. br i1 %tmp.7, label %then, label %endif
  29. then: ; preds = %no_exit
  30. %tmp.9 = load i8*, i8** %p_addr ; <i8*> [#uses=1]
  31. %tmp.10 = load i32, i32* %i ; <i32> [#uses=1]
  32. %tmp.11 = sub i32 %tmp.10, 1 ; <i32> [#uses=1]
  33. %tmp.12 = getelementptr i8, i8* %tmp.9, i32 %tmp.11 ; <i8*> [#uses=1]
  34. %tmp.13 = load i32, i32* %out ; <i32> [#uses=1]
  35. %tmp.14 = trunc i32 %tmp.13 to i8 ; <i8> [#uses=1]
  36. store i8 %tmp.14, i8* %tmp.12
  37. br label %endif
  38. endif: ; preds = %then, %no_exit
  39. %tmp.15 = load i32, i32* %i ; <i32> [#uses=1]
  40. %inc = add i32 %tmp.15, 1 ; <i32> [#uses=1]
  41. store i32 %inc, i32* %i
  42. br label %loopentry
  43. return: ; preds = %loopentry
  44. ret void
  45. }