Preferring cast over seteq with 0

Is there a pass that will transform this:
  %cc = seteq ushort %val, 0

into this:
  %cc = cast ushort %val to bool

Would instcombine be the logical place to do this?


In my situation, this bool value feeds a select instruction. Because
casting inverts the condition, the select would have to switch the
operands, but I think it would be beneficial.

Actually the instcombine pass canonicalizes the other way, turning (cast X to bool) -> (X != 0). Does this not work for you?


I think that the instcombine pass should take care of this situation. Do you have a simple testcase that shows the problem?