onehot_merge.ll 779 B

1234567891011121314151617181920212223242526272829303132333435
  1. ; RUN: opt < %s -instcombine -S | FileCheck %s
  2. ;CHECK: @and_consts
  3. ;CHECK: and i32 %k, 12
  4. ;CHECK: icmp ne i32 %0, 12
  5. ;CHECK: ret
  6. define i1 @and_consts(i32 %k, i32 %c1, i32 %c2) {
  7. bb:
  8. %tmp1 = and i32 4, %k
  9. %tmp2 = icmp eq i32 %tmp1, 0
  10. %tmp5 = and i32 8, %k
  11. %tmp6 = icmp eq i32 %tmp5, 0
  12. %or = or i1 %tmp2, %tmp6
  13. ret i1 %or
  14. }
  15. ;CHECK: @foo1_and
  16. ;CHECK: shl i32 1, %c1
  17. ;CHECK-NEXT: lshr i32 -2147483648, %c2
  18. ;CHECK-NEXT: or i32
  19. ;CHECK-NEXT: and i32
  20. ;CHECK-NEXT: icmp ne i32 %1, %0
  21. ;CHECK: ret
  22. define i1 @foo1_and(i32 %k, i32 %c1, i32 %c2) {
  23. bb:
  24. %tmp = shl i32 1, %c1
  25. %tmp4 = lshr i32 -2147483648, %c2
  26. %tmp1 = and i32 %tmp, %k
  27. %tmp2 = icmp eq i32 %tmp1, 0
  28. %tmp5 = and i32 %tmp4, %k
  29. %tmp6 = icmp eq i32 %tmp5, 0
  30. %or = or i1 %tmp2, %tmp6
  31. ret i1 %or
  32. }