const-base-addr.ll 865 B

123456789101112131415161718192021222324
  1. ; RUN: opt -S -consthoist < %s | FileCheck %s
  2. target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
  3. target triple = "x86_64-apple-macosx10.9.0"
  4. %T = type { i32, i32, i32, i32 }
  5. ; Test if even cheap base addresses are hoisted.
  6. define i32 @test1() nounwind {
  7. ; CHECK-LABEL: @test1
  8. ; CHECK: %const = bitcast i32 12345678 to i32
  9. ; CHECK: %1 = inttoptr i32 %const to %T*
  10. ; CHECK: %addr1 = getelementptr %T, %T* %1, i32 0, i32 1
  11. %addr1 = getelementptr %T, %T* inttoptr (i32 12345678 to %T*), i32 0, i32 1
  12. %tmp1 = load i32, i32* %addr1
  13. %addr2 = getelementptr %T, %T* inttoptr (i32 12345678 to %T*), i32 0, i32 2
  14. %tmp2 = load i32, i32* %addr2
  15. %addr3 = getelementptr %T, %T* inttoptr (i32 12345678 to %T*), i32 0, i32 3
  16. %tmp3 = load i32, i32* %addr3
  17. %tmp4 = add i32 %tmp1, %tmp2
  18. %tmp5 = add i32 %tmp3, %tmp4
  19. ret i32 %tmp5
  20. }