This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Replace addrspacecast with bitcast
AbandonedPublic

Authored by jingyue on May 1 2014, 11:23 AM.

Details

Summary

Fixed a TODO item in r205571.

To eliminate an addrspacecast that changes the underlying element type,
we replace it with a bitcast instead of removing it completely.

Updated the comments to make them consistent with the new code.

Added a test and modified one old test for this change.

Diff Detail

Event Timeline

jingyue updated this revision to Diff 9015.May 1 2014, 11:23 AM
jingyue retitled this revision from to [NVPTX] Replace addrspacecast with bitcast.
jingyue updated this object.
jingyue edited the test plan for this revision. (Show Details)
jingyue added reviewers: jholewinski, arsenm, eliben.
jingyue added a subscriber: Unknown Object (MLST).
arsenm edited edge metadata.May 1 2014, 12:13 PM

I think it would be more appropriate to do this in instcombine

Hi Matt,

Are you referring to your diff http://reviews.llvm.org/D2186? If that diff gets in, I believe the code here can be simplified a lot.

Are you still pushing that diff? To make it more acceptable, one alternative is to implement this canonicalization as a separate pass which can be turned on by the backend when necessary.

arsenm added a comment.May 1 2014, 1:06 PM

I think so. I haven't looked at any of my addrspacecast patches in a while, but I do want to get those in.

Hi Matt,

I found an issue with this patch that causes instcombine to run into an
infinite loops.

The test case is attached. The loop begins with the addrspacecast
instruction:

addrspacecast [16 x i32] addrspace(1)* %arr to i32

> D2186

%0 = addrspacecast [16 x i32] addrspace(1)* %arr to [16 x i32]*
bitcast [16 x i32]* %0 to i32*

> visitBitCast

%0 = addrspacecast [16 x i32] addrspace(1)* %arr to [16 x i32]*
getelementptr [16 x i32]* %0, i64 0, i64 0

> visitGetElementPtr

%0 = getelementptr [16 x i32] addrspace(1)* %arr, i64 0, i64 0
addrspacecast i32 addrspace(1)* %0 to i32*

> commonPointerCastTransforms

addrspacecast [16 x i32] addrspace(1)* %arr to i32

and we have a loop.

I'll try to figure out the root cause today.

Jingyue

Sorry for the confusion. The above comment should go to D2186 instead of here.

Jingyue

jingyue abandoned this revision.Jun 17 2014, 4:07 PM

Subsumed by r211004 and r210375 which canonicalize addrspacecasts with different pointer types