undef.ll 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. ; RUN: opt -instsimplify -S < %s | FileCheck %s
  2. ; @test0
  3. ; CHECK: ret i64 undef
  4. define i64 @test0() {
  5. %r = mul i64 undef, undef
  6. ret i64 %r
  7. }
  8. ; @test1
  9. ; CHECK: ret i64 undef
  10. define i64 @test1() {
  11. %r = mul i64 3, undef
  12. ret i64 %r
  13. }
  14. ; @test2
  15. ; CHECK: ret i64 undef
  16. define i64 @test2() {
  17. %r = mul i64 undef, 3
  18. ret i64 %r
  19. }
  20. ; @test3
  21. ; CHECK: ret i64 0
  22. define i64 @test3() {
  23. %r = mul i64 undef, 6
  24. ret i64 %r
  25. }
  26. ; @test4
  27. ; CHECK: ret i64 0
  28. define i64 @test4() {
  29. %r = mul i64 6, undef
  30. ret i64 %r
  31. }
  32. ; @test5
  33. ; CHECK: ret i64 undef
  34. define i64 @test5() {
  35. %r = and i64 undef, undef
  36. ret i64 %r
  37. }
  38. ; @test6
  39. ; CHECK: ret i64 undef
  40. define i64 @test6() {
  41. %r = or i64 undef, undef
  42. ret i64 %r
  43. }
  44. ; @test7
  45. ; CHECK: ret i64 undef
  46. define i64 @test7() {
  47. %r = udiv i64 undef, 1
  48. ret i64 %r
  49. }
  50. ; @test8
  51. ; CHECK: ret i64 undef
  52. define i64 @test8() {
  53. %r = sdiv i64 undef, 1
  54. ret i64 %r
  55. }
  56. ; @test9
  57. ; CHECK: ret i64 0
  58. define i64 @test9() {
  59. %r = urem i64 undef, 1
  60. ret i64 %r
  61. }
  62. ; @test10
  63. ; CHECK: ret i64 0
  64. define i64 @test10() {
  65. %r = srem i64 undef, 1
  66. ret i64 %r
  67. }
  68. ; @test11
  69. ; CHECK: ret i64 undef
  70. define i64 @test11() {
  71. %r = shl i64 undef, undef
  72. ret i64 %r
  73. }
  74. ; @test11b
  75. ; CHECK: ret i64 undef
  76. define i64 @test11b(i64 %a) {
  77. %r = shl i64 %a, undef
  78. ret i64 %r
  79. }
  80. ; @test12
  81. ; CHECK: ret i64 undef
  82. define i64 @test12() {
  83. %r = ashr i64 undef, undef
  84. ret i64 %r
  85. }
  86. ; @test12b
  87. ; CHECK: ret i64 undef
  88. define i64 @test12b(i64 %a) {
  89. %r = ashr i64 %a, undef
  90. ret i64 %r
  91. }
  92. ; @test13
  93. ; CHECK: ret i64 undef
  94. define i64 @test13() {
  95. %r = lshr i64 undef, undef
  96. ret i64 %r
  97. }
  98. ; @test13b
  99. ; CHECK: ret i64 undef
  100. define i64 @test13b(i64 %a) {
  101. %r = lshr i64 %a, undef
  102. ret i64 %r
  103. }
  104. ; @test14
  105. ; CHECK: ret i1 undef
  106. define i1 @test14() {
  107. %r = icmp slt i64 undef, undef
  108. ret i1 %r
  109. }
  110. ; @test15
  111. ; CHECK: ret i1 undef
  112. define i1 @test15() {
  113. %r = icmp ult i64 undef, undef
  114. ret i1 %r
  115. }
  116. ; @test16
  117. ; CHECK: ret i64 undef
  118. define i64 @test16(i64 %a) {
  119. %r = select i1 undef, i64 %a, i64 undef
  120. ret i64 %r
  121. }
  122. ; @test17
  123. ; CHECK: ret i64 undef
  124. define i64 @test17(i64 %a) {
  125. %r = select i1 undef, i64 undef, i64 %a
  126. ret i64 %r
  127. }
  128. ; @test18
  129. ; CHECK: ret i64 undef
  130. define i64 @test18(i64 %a) {
  131. %r = call i64 (i64) undef(i64 %a)
  132. ret i64 %r
  133. }
  134. ; CHECK-LABEL: @test19
  135. ; CHECK: ret <4 x i8> undef
  136. define <4 x i8> @test19(<4 x i8> %a) {
  137. %b = shl <4 x i8> %a, <i8 8, i8 9, i8 undef, i8 -1>
  138. ret <4 x i8> %b
  139. }
  140. ; CHECK-LABEL: @test20
  141. ; CHECK: ret i32 undef
  142. define i32 @test20(i32 %a) {
  143. %b = udiv i32 %a, 0
  144. ret i32 %b
  145. }
  146. ; CHECK-LABEL: @test21
  147. ; CHECK: ret i32 undef
  148. define i32 @test21(i32 %a) {
  149. %b = sdiv i32 %a, 0
  150. ret i32 %b
  151. }
  152. ; CHECK-LABEL: @test22
  153. ; CHECK: ret i32 undef
  154. define i32 @test22(i32 %a) {
  155. %b = ashr exact i32 undef, %a
  156. ret i32 %b
  157. }
  158. ; CHECK-LABEL: @test23
  159. ; CHECK: ret i32 undef
  160. define i32 @test23(i32 %a) {
  161. %b = lshr exact i32 undef, %a
  162. ret i32 %b
  163. }
  164. ; CHECK-LABEL: @test24
  165. ; CHECK: ret i32 undef
  166. define i32 @test24() {
  167. %b = udiv i32 undef, 0
  168. ret i32 %b
  169. }
  170. ; CHECK-LABEL: @test25
  171. ; CHECK: ret i32 undef
  172. define i32 @test25() {
  173. %b = lshr i32 0, undef
  174. ret i32 %b
  175. }
  176. ; CHECK-LABEL: @test26
  177. ; CHECK: ret i32 undef
  178. define i32 @test26() {
  179. %b = ashr i32 0, undef
  180. ret i32 %b
  181. }
  182. ; CHECK-LABEL: @test27
  183. ; CHECK: ret i32 undef
  184. define i32 @test27() {
  185. %b = shl i32 0, undef
  186. ret i32 %b
  187. }
  188. ; CHECK-LABEL: @test28
  189. ; CHECK: ret i32 undef
  190. define i32 @test28(i32 %a) {
  191. %b = shl nsw i32 undef, %a
  192. ret i32 %b
  193. }
  194. ; CHECK-LABEL: @test29
  195. ; CHECK: ret i32 undef
  196. define i32 @test29(i32 %a) {
  197. %b = shl nuw i32 undef, %a
  198. ret i32 %b
  199. }
  200. ; CHECK-LABEL: @test30
  201. ; CHECK: ret i32 undef
  202. define i32 @test30(i32 %a) {
  203. %b = shl nsw nuw i32 undef, %a
  204. ret i32 %b
  205. }
  206. ; CHECK-LABEL: @test31
  207. ; CHECK: ret i32 0
  208. define i32 @test31(i32 %a) {
  209. %b = shl i32 undef, %a
  210. ret i32 %b
  211. }
  212. ; CHECK-LABEL: @test32
  213. ; CHECK: ret i32 undef
  214. define i32 @test32(i32 %a) {
  215. %b = shl i32 undef, 0
  216. ret i32 %b
  217. }
  218. ; CHECK-LABEL: @test33
  219. ; CHECK: ret i32 undef
  220. define i32 @test33(i32 %a) {
  221. %b = ashr i32 undef, 0
  222. ret i32 %b
  223. }
  224. ; CHECK-LABEL: @test34
  225. ; CHECK: ret i32 undef
  226. define i32 @test34(i32 %a) {
  227. %b = lshr i32 undef, 0
  228. ret i32 %b
  229. }
  230. ; CHECK-LABEL: @test35
  231. ; CHECK: ret i32 undef
  232. define i32 @test35(<4 x i32> %V) {
  233. %b = extractelement <4 x i32> %V, i32 4
  234. ret i32 %b
  235. }
  236. ; CHECK-LABEL: @test36
  237. ; CHECK: ret i32 undef
  238. define i32 @test36(i32 %V) {
  239. %b = extractelement <4 x i32> undef, i32 %V
  240. ret i32 %b
  241. }