not.ll 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ; This test makes sure that these instructions are properly eliminated.
  2. ;
  3. ; RUN: opt < %s -instcombine -S | FileCheck %s
  4. ; CHECK-NOT: xor
  5. define i32 @test1(i32 %A) {
  6. %B = xor i32 %A, -1 ; <i32> [#uses=1]
  7. %C = xor i32 %B, -1 ; <i32> [#uses=1]
  8. ret i32 %C
  9. }
  10. define i1 @test2(i32 %A, i32 %B) {
  11. ; Can change into setge
  12. %cond = icmp sle i32 %A, %B ; <i1> [#uses=1]
  13. %Ret = xor i1 %cond, true ; <i1> [#uses=1]
  14. ret i1 %Ret
  15. }
  16. ; Test that demorgans law can be instcombined
  17. define i32 @test3(i32 %A, i32 %B) {
  18. %a = xor i32 %A, -1 ; <i32> [#uses=1]
  19. %b = xor i32 %B, -1 ; <i32> [#uses=1]
  20. %c = and i32 %a, %b ; <i32> [#uses=1]
  21. %d = xor i32 %c, -1 ; <i32> [#uses=1]
  22. ret i32 %d
  23. }
  24. ; Test that demorgens law can work with constants
  25. define i32 @test4(i32 %A, i32 %B) {
  26. %a = xor i32 %A, -1 ; <i32> [#uses=1]
  27. %c = and i32 %a, 5 ; <i32> [#uses=1]
  28. %d = xor i32 %c, -1 ; <i32> [#uses=1]
  29. ret i32 %d
  30. }
  31. ; test the mirror of demorgans law...
  32. define i32 @test5(i32 %A, i32 %B) {
  33. %a = xor i32 %A, -1 ; <i32> [#uses=1]
  34. %b = xor i32 %B, -1 ; <i32> [#uses=1]
  35. %c = or i32 %a, %b ; <i32> [#uses=1]
  36. %d = xor i32 %c, -1 ; <i32> [#uses=1]
  37. ret i32 %d
  38. }
  39. ; PR2298
  40. define zeroext i8 @test6(i32 %a, i32 %b) nounwind {
  41. entry:
  42. %tmp1not = xor i32 %a, -1 ; <i32> [#uses=1]
  43. %tmp2not = xor i32 %b, -1 ; <i32> [#uses=1]
  44. %tmp3 = icmp slt i32 %tmp1not, %tmp2not ; <i1> [#uses=1]
  45. %retval67 = zext i1 %tmp3 to i8 ; <i8> [#uses=1]
  46. ret i8 %retval67
  47. }
  48. define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
  49. %cond = icmp sle <2 x i32> %A, %B
  50. %Ret = xor <2 x i1> %cond, <i1 true, i1 true>
  51. ret <2 x i1> %Ret
  52. }