2003-05-02-LoadHoist.ll 695 B

1234567891011121314151617181920212223
  1. ; This testcase tests for a problem where LICM hoists loads out of a loop
  2. ; despite the fact that calls to unknown functions may modify what is being
  3. ; loaded from. Basically if the load gets hoisted, the subtract gets turned
  4. ; into a constant zero.
  5. ;
  6. ; RUN: opt < %s -licm -gvn -instcombine -S | grep load
  7. @X = global i32 7 ; <i32*> [#uses=2]
  8. declare void @foo()
  9. define i32 @test(i1 %c) {
  10. %A = load i32, i32* @X ; <i32> [#uses=1]
  11. br label %Loop
  12. Loop: ; preds = %Loop, %0
  13. call void @foo( )
  14. ;; Should not hoist this load!
  15. %B = load i32, i32* @X ; <i32> [#uses=1]
  16. br i1 %c, label %Loop, label %Out
  17. Out: ; preds = %Loop
  18. %C = sub i32 %A, %B ; <i32> [#uses=1]
  19. ret i32 %C
  20. }