select-select.ll 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. ; RUN: opt -instcombine -S < %s | FileCheck %s
  2. ; CHECK: @foo1
  3. define float @foo1(float %a) #0 {
  4. ; CHECK-NOT: xor
  5. %b = fcmp ogt float %a, 0.000000e+00
  6. %c = select i1 %b, float %a, float 0.000000e+00
  7. %d = fcmp olt float %c, 1.000000e+00
  8. %f = select i1 %d, float %c, float 1.000000e+00
  9. ret float %f
  10. }
  11. ; CHECK: @foo2
  12. define float @foo2(float %a) #0 {
  13. ; CHECK-NOT: xor
  14. %b = fcmp ogt float %a, 0.000000e+00
  15. %c = select i1 %b, float %a, float 0.000000e+00
  16. %d = fcmp olt float %c, 1.000000e+00
  17. %e = select i1 %b, float %a, float 0.000000e+00
  18. %f = select i1 %d, float %e, float 1.000000e+00
  19. ret float %f
  20. }
  21. ; CHECK-LABEL: @foo3
  22. define <2 x i32> @foo3(<2 x i1> %vec_bool, i1 %bool, <2 x i32> %V) {
  23. ; CHECK: %[[sel0:.*]] = select <2 x i1> %vec_bool, <2 x i32> zeroinitializer, <2 x i32> %V
  24. ; CHECK: %[[sel1:.*]] = select i1 %bool, <2 x i32> %[[sel0]], <2 x i32> %V
  25. ; CHECK: ret <2 x i32> %[[sel1]]
  26. %sel0 = select <2 x i1> %vec_bool, <2 x i32> zeroinitializer, <2 x i32> %V
  27. %sel1 = select i1 %bool, <2 x i32> %sel0, <2 x i32> %V
  28. ret <2 x i32> %sel1
  29. }
  30. attributes #0 = { nounwind readnone ssp uwtable }