zext.ll 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ; Tests to make sure elimination of casts is working correctly
  2. ; RUN: opt < %s -instcombine -S | FileCheck %s
  3. define i64 @test_sext_zext(i16 %A) {
  4. %c1 = zext i16 %A to i32 ; <i32> [#uses=1]
  5. %c2 = sext i32 %c1 to i64 ; <i64> [#uses=1]
  6. ret i64 %c2
  7. ; CHECK-LABEL: @test_sext_zext
  8. ; CHECK-NOT: %c1
  9. ; CHECK: %c2 = zext i16 %A to i64
  10. ; CHECK: ret i64 %c2
  11. }
  12. define <2 x i64> @test2(<2 x i1> %A) {
  13. %xor = xor <2 x i1> %A, <i1 true, i1 true>
  14. %zext = zext <2 x i1> %xor to <2 x i64>
  15. ret <2 x i64> %zext
  16. ; CHECK-LABEL: @test2
  17. ; CHECK-NEXT: zext <2 x i1> %A to <2 x i64>
  18. ; CHECK-NEXT: xor <2 x i64> %1, <i64 1, i64 1>
  19. }
  20. define <2 x i64> @test3(<2 x i64> %A) {
  21. %trunc = trunc <2 x i64> %A to <2 x i32>
  22. %and = and <2 x i32> %trunc, <i32 23, i32 42>
  23. %zext = zext <2 x i32> %and to <2 x i64>
  24. ret <2 x i64> %zext
  25. ; CHECK-LABEL: @test3
  26. ; CHECK-NEXT: and <2 x i64> %A, <i64 23, i64 42>
  27. }
  28. define <2 x i64> @test4(<2 x i64> %A) {
  29. %trunc = trunc <2 x i64> %A to <2 x i32>
  30. %and = and <2 x i32> %trunc, <i32 23, i32 42>
  31. %xor = xor <2 x i32> %and, <i32 23, i32 42>
  32. %zext = zext <2 x i32> %xor to <2 x i64>
  33. ret <2 x i64> %zext
  34. ; CHECK-LABEL: @test4
  35. ; CHECK-NEXT: xor <2 x i64> %A, <i64 4294967295, i64 4294967295>
  36. ; CHECK-NEXT: and <2 x i64> %1, <i64 23, i64 42>
  37. }