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? Thanks.
On Thu, May 19, 2005 at 03:27:02PM -0500, Eric Zimmerman wrote:> 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.
On Thu, 19 May 2005, Eric Zimmerman wrote:> 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?Actually the instcombine pass canonicalizes the other way, turning (cast X to bool) -> (X != 0). Does this not work for you? -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
On Thu, 19 May 2005, Eric Zimmerman wrote:> On Thu, May 19, 2005 at 03:27:02PM -0500, Eric Zimmerman wrote: >> 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.I think that the instcombine pass should take care of this situation. Do you have a simple testcase that shows the problem? -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/