and-or.ll 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ; RUN: opt < %s -instcombine -S | grep "and i32 %a, 1" | count 4
  2. ; RUN: opt < %s -instcombine -S | grep "or i32 %0, %b" | count 4
  3. define i32 @func1(i32 %a, i32 %b) nounwind readnone {
  4. entry:
  5. %0 = or i32 %b, %a ; <i32> [#uses=1]
  6. %1 = and i32 %0, 1 ; <i32> [#uses=1]
  7. %2 = and i32 %b, -2 ; <i32> [#uses=1]
  8. %3 = or i32 %1, %2 ; <i32> [#uses=1]
  9. ret i32 %3
  10. }
  11. define i32 @func2(i32 %a, i32 %b) nounwind readnone {
  12. entry:
  13. %0 = or i32 %a, %b ; <i32> [#uses=1]
  14. %1 = and i32 1, %0 ; <i32> [#uses=1]
  15. %2 = and i32 -2, %b ; <i32> [#uses=1]
  16. %3 = or i32 %1, %2 ; <i32> [#uses=1]
  17. ret i32 %3
  18. }
  19. define i32 @func3(i32 %a, i32 %b) nounwind readnone {
  20. entry:
  21. %0 = or i32 %b, %a ; <i32> [#uses=1]
  22. %1 = and i32 %0, 1 ; <i32> [#uses=1]
  23. %2 = and i32 %b, -2 ; <i32> [#uses=1]
  24. %3 = or i32 %2, %1 ; <i32> [#uses=1]
  25. ret i32 %3
  26. }
  27. define i32 @func4(i32 %a, i32 %b) nounwind readnone {
  28. entry:
  29. %0 = or i32 %a, %b ; <i32> [#uses=1]
  30. %1 = and i32 1, %0 ; <i32> [#uses=1]
  31. %2 = and i32 -2, %b ; <i32> [#uses=1]
  32. %3 = or i32 %2, %1 ; <i32> [#uses=1]
  33. ret i32 %3
  34. }