[llvm-commits] [llvm] r126964 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h test/CodeGen/X86/umulo-64.ll
Eric Christopher
echristo at apple.com
Fri Mar 4 12:35:54 PST 2011
On Mar 4, 2011, at 3:55 AM, Erik Olofsson wrote:
> Check out hackers delight. It usually has trickery for cases like this. Google:
> hacker's delight check for multiplication overflow
>
>>
>> Not sure what anything other than gcc does. For gcc they kind of avoid some
>> of the problem we're trying to solve here. If -ftrapv is called they use a
>> libcall that aborts if the multiply overflows. Otherwise they just use straight
>> mul. This probably won't work for us because one of the big places that
>> clang uses this built-in is to check whether or not an allocation overflows so
>> that they can throw an exception for c++. And yes, I'd rather not have to split
>> the block for every allocation just to make an "is this zero" check before
>> doing a divide. Especially since it'd be always false in the normal case.
>>
>> I'm uncertain what a more modern gcc does in the case that they actually
>> want to do something with the overflow flag.
I'm tempted to want to create a new libcall just for this. There's normally the mulv<mode>3 call from libgcc/compiler-rt that is used in the trapv case to abort, but that's not what we want here - we want to be able to throw in C++.
The cases are fairly long and obnoxious if you can't promote the operands to a larger mode - and I don't think that it's an option here.
-eric
More information about the llvm-commits
mailing list