<html><body style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 12px;"><div>The following combine(-enabling transformation) makes me uncomfortable:</div><div><br /></div><div> gep(addrspacecast(gep p0) to p1)</div><div><br /></div><div> addrspacecast(gep(gep p0)) to p1</div><div><br /></div><div>It's applied at visitAddrSpaceCast in InstCombineCasts.cpp.</div><div><br /></div><div>Before this, I'd always assumed address spaces were very much "user domain". Datalayout even supports marking a space as "non-integral", to designate that manipulation as bits is impossible. In my case, I have a different byte width in p1 over p0 (I know - but we all knew it was coming). All of p0 can be addressed in p1, but the reverse transformation is only sometimes possible as GEPs behave differently on the other side of the cast. This transformation of course breaks that.</div><div><br /></div><div><div style="color:rgb(0,0,0);font-size:12px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;word-spacing:0px;">By my reading of ISO 18037:2006(E), it is required that if one address in p0 can be cast to p1, they all can, but I cannot find any requirements placed on the reverse operation - and further, this is a C standard, not a low-level machine.</div><div style="color:rgb(0,0,0);font-size:12px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;word-spacing:0px;"><br /></div><div style="color:rgb(0,0,0);font-size:12px;font-style:normal;font-variant:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;word-spacing:0px;">I realise this may be seen as an abuse of mechanics, but is it really intended that addrspacecast and geps can be rearranged in all circumstances, in all address space combinations? To me, the fewer assumptions made about addrspaces the better - callbacks should be used before optimising past them.<br /></div></div></body></html>