load-bitcast32.ll 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ; RUN: opt -instcombine -S < %s | FileCheck %s
  2. target datalayout = "p:32:32:32"
  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 i64*, i64**
  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 i32, i32*
  37. ; CHECK: zext
  38. ; CHECK: ret
  39. %a = bitcast i8* %x to i64**
  40. %b = load i64*, i64** %a
  41. %c = ptrtoint i64* %b to i64
  42. ret i64 %c
  43. }
  44. define i32 @test5(i8* %x) {
  45. entry:
  46. ; CHECK-LABEL: @test5(
  47. ; CHECK: load i32, i32*
  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 i32, i32*
  58. ; CHECK: zext
  59. ; CHECK: ret
  60. %a = bitcast i8* %x to i32**
  61. %b = load i32*, i32** %a
  62. %c = ptrtoint i32* %b to i64
  63. ret i64 %c
  64. }