constantsTest.3.2.ll 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. ; RUN: llvm-dis < %s.bc| FileCheck %s
  2. ; constantsTest.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
  3. ; The test checks that LLVM does not misread binary float instructions of
  4. ; older bitcode files.
  5. ;global variable address
  6. ; CHECK: @X = global i32 0
  7. @X = global i32 0
  8. ; CHECK: @Y = global i32 1
  9. @Y = global i32 1
  10. ; CHECK: @Z = global [2 x i32*] [i32* @X, i32* @Y]
  11. @Z = global [2 x i32*] [i32* @X, i32* @Y]
  12. define void @SimpleConstants(i32 %x) {
  13. entry:
  14. ; null
  15. ; CHECK: store i32 %x, i32* null
  16. store i32 %x, i32* null
  17. ; boolean
  18. ; CHECK-NEXT: %res1 = fcmp true float 1.000000e+00, 1.000000e+00
  19. %res1 = fcmp true float 1.0, 1.0
  20. ; CHECK-NEXT: %res2 = fcmp false float 1.000000e+00, 1.000000e+00
  21. %res2 = fcmp false float 1.0, 1.0
  22. ;integer
  23. ; CHECK-NEXT: %res3 = add i32 0, 0
  24. %res3 = add i32 0, 0
  25. ;float
  26. ; CHECK-NEXT: %res4 = fadd float 0.000000e+00, 0.000000e+00
  27. %res4 = fadd float 0.0, 0.0
  28. ret void
  29. }
  30. define void @ComplexConstants(<2 x i32> %x){
  31. entry:
  32. ;constant structure
  33. ; CHECK: %res1 = extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
  34. %res1 = extractvalue {i32, float} {i32 1, float 2.0}, 0
  35. ;const array
  36. ; CHECK-NEXT: %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
  37. %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
  38. ;const vector
  39. ; CHECK-NEXT: %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
  40. %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
  41. ;zeroinitializer
  42. ; CHECK-NEXT: %res4 = add <2 x i32> %x, zeroinitializer
  43. %res4 = add <2 x i32> %x, zeroinitializer
  44. ret void
  45. }
  46. define void @OtherConstants(i32 %x, i8* %Addr){
  47. entry:
  48. ;undef
  49. ; CHECK: %res1 = add i32 %x, undef
  50. %res1 = add i32 %x, undef
  51. ;poison
  52. ; CHECK-NEXT: %poison = sub nuw i32 0, 1
  53. %poison = sub nuw i32 0, 1
  54. ;address of basic block
  55. ; CHECK-NEXT: %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
  56. %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
  57. br label %Next
  58. Next:
  59. ret void
  60. }
  61. define void @OtherConstants2(){
  62. entry:
  63. ; CHECK: trunc i32 1 to i8
  64. trunc i32 1 to i8
  65. ; CHECK-NEXT: zext i8 1 to i32
  66. zext i8 1 to i32
  67. ; CHECK-NEXT: sext i8 1 to i32
  68. sext i8 1 to i32
  69. ; CHECK-NEXT: fptrunc double 1.000000e+00 to float
  70. fptrunc double 1.0 to float
  71. ; CHECK-NEXT: fpext float 1.000000e+00 to double
  72. fpext float 1.0 to double
  73. ; CHECK-NEXT: fptosi float 1.000000e+00 to i32
  74. fptosi float 1.0 to i32
  75. ; CHECK-NEXT: uitofp i32 1 to float
  76. uitofp i32 1 to float
  77. ; CHECK-NEXT: sitofp i32 -1 to float
  78. sitofp i32 -1 to float
  79. ; CHECK-NEXT: ptrtoint i32* @X to i32
  80. ptrtoint i32* @X to i32
  81. ; CHECK-NEXT: inttoptr i8 1 to i8*
  82. inttoptr i8 1 to i8*
  83. ; CHECK-NEXT: bitcast i32 1 to <2 x i16>
  84. bitcast i32 1 to <2 x i16>
  85. ; CHECK-NEXT: getelementptr i32, i32* @X, i32 0
  86. getelementptr i32, i32* @X, i32 0
  87. ; CHECK-NEXT: getelementptr inbounds i32, i32* @X, i32 0
  88. getelementptr inbounds i32, i32* @X, i32 0
  89. ; CHECK: select i1 true, i32 1, i32 0
  90. select i1 true ,i32 1, i32 0
  91. ; CHECK-NEXT: icmp eq i32 1, 0
  92. icmp eq i32 1, 0
  93. ; CHECK-NEXT: fcmp oeq float 1.000000e+00, 0.000000e+00
  94. fcmp oeq float 1.0, 0.0
  95. ; CHECK-NEXT: extractelement <2 x i32> <i32 1, i32 1>, i32 1
  96. extractelement <2 x i32> <i32 1, i32 1>, i32 1
  97. ; CHECK-NEXT: insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
  98. insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
  99. ; CHECK-NEXT: shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  100. shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
  101. ; CHECK-NEXT: extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
  102. extractvalue { i32, float } { i32 1, float 2.0 }, 0
  103. ; CHECK-NEXT: insertvalue { i32, float } { i32 1, float 2.000000e+00 }, i32 0, 0
  104. insertvalue { i32, float } { i32 1, float 2.0 }, i32 0, 0
  105. ret void
  106. }