[llvm] r187635 - Teach InstructionSimplify about pointer address spaces
Matt Arsenault
arsenm2 at gmail.com
Fri Aug 2 17:17:31 PDT 2013
On Aug 2, 2013, at 16:54 , Eli Friedman <eli.friedman at gmail.com> wrote:
> On Thu, Aug 1, 2013 at 5:10 PM, Matt Arsenault
> <Matthew.Arsenault at amd.com> wrote:
>> Author: arsenm
>> Date: Thu Aug 1 19:10:44 2013
>> New Revision: 187635
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=187635&view=rev
>> Log:
>> Teach InstructionSimplify about pointer address spaces
>>
>> Modified:
>> llvm/trunk/lib/Analysis/InstructionSimplify.cpp
>
> Testcase?
My tests for these require the other pieces up to InstCombine to be consistent, so the test will come with that change.
>
>> Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=187635&r1=187634&r2=187635&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
>> +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu Aug 1 19:10:44 2013
>> @@ -676,7 +676,8 @@ static Constant *stripAndComputeConstant
>> if (!TD)
>> return ConstantInt::get(IntegerType::get(V->getContext(), 64), 0);
>>
>> - unsigned IntPtrWidth = TD->getPointerSizeInBits();
>> + unsigned AS = V->getType()->getPointerAddressSpace();
>> + unsigned IntPtrWidth = TD->getPointerSizeInBits(AS);
>> APInt Offset = APInt::getNullValue(IntPtrWidth);
>>
>> // Even though we don't look through PHI nodes, we could be called on an
>> @@ -689,7 +690,11 @@ static Constant *stripAndComputeConstant
>> break;
>> V = GEP->getPointerOperand();
>> } else if (Operator::getOpcode(V) == Instruction::BitCast) {
>> - V = cast<Operator>(V)->getOperand(0);
>> + Value *Op0 = cast<Operator>(V)->getOperand(0);
>> + assert(TD->getPointerTypeSizeInBits(V->getType()) ==
>> + TD->getPointerTypeSizeInBits(Op0->getType()) &&
>> + "Bitcasting between pointers from different size address spaces");
>> + V = Op0;
>
>
> The verifier already checks this, no?
>
Yes, but I did this before I did the verifier. It's not really needed anymore
More information about the llvm-commits
mailing list