[llvm-commits] [llvm] r51216 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/2008-05-17-FoldIntToPtr.ll

Chris Lattner clattner at apple.com
Sat May 17 06:43:38 PDT 2008


On May 17, 2008, at 6:02 AM, Gordon Henriksen wrote:

> On 2008-05-17, at 05:03, Nick Lewycky wrote:
>
>> +    case Instruction::PtrToInt:
>> +    case Instruction::IntToPtr:
>> +      // inttoptr(x1) != inttoptr(x2) iff x1 != x2
>
> Nick, one way to write an 'is 64-bit' ConstantExpr would be to as
> (icmp ne (inttoptr i64 0x100000000), (inttoptr i64 0x0)). Likewise,
> ptrtoint can also perform a target-dependent truncation. Are you
> correct re these behaviors?

I was about to mention this :).  This isn't safe.  It needs to be done  
in lib/Analysis/ConstantFolding.cpp, where it has access to  
targetdata.  After that code handles it, we need to make llvm-gcc call  
into that folding logic where possible.  It would be nice to have an  
FoldingIRBuilder that used the libanalysis constant folding routines  
(which require a TD).

-Chris



More information about the llvm-commits mailing list