[llvm-commits] [llvm] r147286 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/preserve-branchweights.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Jan 23 10:35:32 PST 2012


On Jan 22, 2012, at 8:25 PM, Nick Lewycky wrote:

> So, I've tried to implement this and ended up with the patch attached. Any suggestions for improvement would be appreciated.

Thanks, Nick. The patch looks good to me.

BTW, are you actually benefiting from computing everything in APInt? We know the ranges of these values.

> You still need the GCD stuff, otherwise you could end up with branch weights 'i32 5', 'i32 5'. That might be legal, but it's certainly not optimal.

I don't think it actually hurts, but you get some really weird rounding behavior based on number theoretic happenstance.

These weights really should have been floats, but we had to approximate with ints because we need reproducible results across platforms. They are approximations of real numbers, they are not intended as 'mathematical integers'.

Let me put it this way: If the weights were floats, would you be computing the GCD of the mantissas?

/jakob





More information about the llvm-commits mailing list