load-bitcast64.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ; RUN: opt -instcombine -S < %s | FileCheck %s
  2. target datalayout = "p:64:64:64"
  3. define i64* @test1(i8* %x) {
  4. entry:
  5. ; CHECK-LABEL: @test1(
  6. ; CHECK: load i64*, i64**
  7. ; CHECK: ret
  8. %a = bitcast i8* %x to i64*
  9. %b = load i64, i64* %a
  10. %c = inttoptr i64 %b to i64*
  11. ret i64* %c
  12. }
  13. define i32* @test2(i8* %x) {
  14. entry:
  15. ; CHECK-LABEL: @test2(
  16. ; CHECK: load i32, i32*
  17. ; CHECK: ret
  18. %a = bitcast i8* %x to i32*
  19. %b = load i32, i32* %a
  20. %c = inttoptr i32 %b to i32*
  21. ret i32* %c
  22. }
  23. define i64* @test3(i8* %x) {
  24. entry:
  25. ; CHECK-LABEL: @test3(
  26. ; CHECK: load i32, i32*
  27. ; CHECK: ret
  28. %a = bitcast i8* %x to i32*
  29. %b = load i32, i32* %a
  30. %c = inttoptr i32 %b to i64*
  31. ret i64* %c
  32. }
  33. define i64 @test4(i8* %x) {
  34. entry:
  35. ; CHECK-LABEL: @test4(
  36. ; CHECK: load i64, i64*
  37. ; CHECK: ret
  38. %a = bitcast i8* %x to i64**
  39. %b = load i64*, i64** %a
  40. %c = ptrtoint i64* %b to i64
  41. ret i64 %c
  42. }
  43. define i32 @test5(i8* %x) {
  44. entry:
  45. ; CHECK-LABEL: @test5(
  46. ; CHECK: load i64, i64*
  47. ; CHECK: trunc
  48. ; CHECK: ret
  49. %a = bitcast i8* %x to i32**
  50. %b = load i32*, i32** %a
  51. %c = ptrtoint i32* %b to i32
  52. ret i32 %c
  53. }
  54. define i64 @test6(i8* %x) {
  55. entry:
  56. ; CHECK-LABEL: @test6(
  57. ; CHECK: load i64, i64*
  58. ; CHECK: ret
  59. %a = bitcast i8* %x to i32**
  60. %b = load i32*, i32** %a
  61. %c = ptrtoint i32* %b to i64
  62. ret i64 %c
  63. }