This is an archive of the discontinued LLVM Phabricator instance.

Canonicalize addrspacecast ConstExpr between different pointer types
ClosedPublic

Authored by jingyue on Jun 13 2014, 10:21 AM.

Details

Summary

As a follow-up to r210375 which canonicalizes addrspacecast
instructions, this patch canonicalizes addrspacecast constant
expressions.

Given clang uses ConstantExpr::getAddrSpaceCast to emit addrspacecast
cosntant expressions, this patch is also a step towards having the
frontend emit canonicalized addrspacecasts.

Update three affected tests in addrspacecast-alias.ll,
access-non-generic.ll and constant-fold-gep.ll and added one new test in
constant-fold-address-space-pointer.ll

Diff Detail

Event Timeline

jingyue updated this revision to Diff 10397.Jun 13 2014, 10:21 AM
jingyue retitled this revision from to Canonicalize addrspacecast ConstExpr between different pointer types.
jingyue updated this object.
jingyue edited the test plan for this revision. (Show Details)
jingyue added reviewers: arsenm, eliben, meheff.
jingyue added a subscriber: Unknown Object (MLST).
arsenm added inline comments.Jun 13 2014, 11:24 AM
lib/IR/Constants.cpp
1708–1709

This is a good place to use dyn_cast<VectorType> instead of checking for a vector and then cast<> inside of the getVectorNumElements

jingyue updated this revision to Diff 10405.Jun 13 2014, 2:02 PM

Thanks! I also piggybacked a similar change in InstCombine

meheff accepted this revision.Jun 13 2014, 2:40 PM
meheff edited edge metadata.

Couple nits. Otherwise LGTM.

test/CodeGen/NVPTX/access-non-generic.ll
78

spelling nit: bitcast.

81

Is there also an addrspacecast that you could/should check for? It's more of a question than a request.

This revision is now accepted and ready to land.Jun 13 2014, 2:40 PM
jingyue added inline comments.Jun 13 2014, 2:48 PM
test/CodeGen/NVPTX/access-non-generic.ll
78

Will fix

81

nvptx-favor-non-generic will fold the addrspacecast into the load, so what's after the bitcast will be something like:

load i32 addrspace(3)* %1

I'll check for this addrspace-equipped load in the test as well. Thanks!

Comments inlined

eliben accepted this revision.Jun 13 2014, 2:52 PM
eliben edited edge metadata.

LGTM

jingyue updated this revision to Diff 10409.Jun 13 2014, 3:40 PM
jingyue edited edge metadata.

make the test @ld_int_from_float more explicit

jingyue updated this revision to Diff 10430.Jun 15 2014, 2:42 PM

Fixed an obvious typo

jingyue closed this revision.Jun 15 2014, 2:49 PM

Committed in r211004