[llvm-commits] [llvm] r78714 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/exact-sdiv.ll

Nick Lewycky nicholas at mxc.ca
Tue Aug 11 20:35:03 PDT 2009


Chris Lattner wrote:
> On Aug 11, 2009, at 3:36 PM, Dan Gohman wrote:
> 
>> On Aug 11, 2009, at 3:16 PM, Eli Friedman wrote:
>>
>>
>>> On Tue, Aug 11, 2009 at 1:47 PM, Dan Gohman<gohman at apple.com> wrote:
>>>
>>>> Author: djg
>>>>
>>>> Date: Tue Aug 11 15:47:47 2009
>>>>
>>>> New Revision: 78714
>>>>
>>>>
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=78714&view=rev
>>>>
>>>> Log:
>>>>
>>>> Optimize exact sdiv by a constant power of 2 to ashr.
>>>>
>>> Do you think we want to optimize exact sdiv by any constant integer  
>>> in
>>> instcombine, or should we put that off to CodeGen?  For example,
>>> should instcombine optimize "exact sdiv i32 %x, 3" to "mul i32 %x,
>>> 2863311531"?
>> Instcombine sounds reasonable for this kind of thing, provided that it
>> happens after any other instcombine rules that know about exact sdiv.
> 
> I agree, instcombine should canonicalize a sdiv to a single mul if  
> possible.

I like having one way to represent a given operation. But it's not 
obvious from "mul i32 %x, 2863311531" that the result is guaranteed to 
be slt %x.

Maybe that's easy enough to determine that it could go into a helper 
function, but I'd like to see that algorithm first :)

Nick




More information about the llvm-commits mailing list