udiv_select_to_select_shift.ll 538 B

1234567891011121314151617
  1. ; Test that this transform works:
  2. ; udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2)
  3. ;
  4. ; RUN: opt < %s -instcombine -S -o %t
  5. ; RUN: not grep select %t
  6. ; RUN: grep lshr %t | count 2
  7. ; RUN: not grep udiv %t
  8. define i64 @test(i64 %X, i1 %Cond ) {
  9. entry:
  10. %divisor1 = select i1 %Cond, i64 16, i64 8
  11. %quotient1 = udiv i64 %X, %divisor1
  12. %divisor2 = select i1 %Cond, i64 8, i64 0
  13. %quotient2 = udiv i64 %X, %divisor2
  14. %sum = add i64 %quotient1, %quotient2
  15. ret i64 %sum
  16. }