On Mon, 2006-10-23 at 22:52 -0700, Chris Lattner wrote: > I strongly recommend adding a transformation to instcombine that will > produce more divs with such operands. For example, changing something > like: > > %X = cast uint %A to int > %Y = sdiv int %X, 1234 > %Z = cast int %Y to uint > into: > %Z = sdiv uint %A, 1234 > Fortunately, instcombine already does this for other operations > (mul/add/and/or/xor, etc) at line 5658 of Instcombine in CVS. Please > add a case there for UDIV/SDIV. This will hopefully help flush out > bugs in the patch that I didn't catch.
I took a look at doing this but there are corner cases I'm dealing with. If the input is: %X = cast uint %A to int %Y = sdiv int %X, -1234 %Z = cast int %Y to uint then its a little more challenging to make the sdiv work with unsigned operands. So I'm assuming this only works with positive constants. There are other corner cases too, like if the 2nd operand isn't a constant but an instruction. I would rather not risk breaking things now by trying to add a new transform. After implementing all your other suggestions the patch is passing all the tests. Can we implement this later? Reid. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits