apint-or.ll 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. ; RUN: opt < %s -instsimplify -S | not grep or
  2. ; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
  3. define i39 @test1(i39 %V, i39 %M) {
  4. ;; If we have: ((V + N) & C1) | (V & C2)
  5. ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
  6. ;; replace with V+N.
  7. %C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
  8. %N = and i39 %M, 274877906944
  9. %A = add i39 %V, %N
  10. %B = and i39 %A, %C1
  11. %D = and i39 %V, 274877906943
  12. %R = or i39 %B, %D
  13. ret i39 %R
  14. ; CHECK-LABEL @test1
  15. ; CHECK-NEXT: and {{.*}}, -274877906944
  16. ; CHECK-NEXT: add
  17. ; CHECK-NEXT: ret
  18. }
  19. ; Test the case where Integer BitWidth > 64 && BitWidth <= 1024.
  20. define i399 @test2(i399 %V, i399 %M) {
  21. ;; If we have: ((V + N) & C1) | (V & C2)
  22. ;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
  23. ;; replace with V+N.
  24. %C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
  25. %N = and i399 %M, 18446742974197923840
  26. %A = add i399 %V, %N
  27. %B = and i399 %A, %C1
  28. %D = and i399 %V, 274877906943
  29. %R = or i399 %B, %D
  30. ret i399 %R
  31. ; CHECK-LABEL @test2
  32. ; CHECK-NEXT: and {{.*}}, 18446742974197923840
  33. ; CHECK-NEXT: add
  34. ; CHECK-NEXT: ret
  35. }