@@ -1916,29 +1916,6 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
19161916 return nullptr ;
19171917}
19181918
1919- // / Implement the transforms for cast of pointer (bitcast/ptrtoint)
1920- Instruction *InstCombinerImpl::commonPointerCastTransforms (CastInst &CI) {
1921- Value *Src = CI.getOperand (0 );
1922-
1923- if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Src)) {
1924- // If casting the result of a getelementptr instruction with no offset, turn
1925- // this into a cast of the original pointer!
1926- if (GEP->hasAllZeroIndices () &&
1927- // If CI is an addrspacecast and GEP changes the poiner type, merging
1928- // GEP into CI would undo canonicalizing addrspacecast with different
1929- // pointer types, causing infinite loops.
1930- (!isa<AddrSpaceCastInst>(CI) ||
1931- GEP->getType () == GEP->getPointerOperandType ())) {
1932- // Changing the cast operand is usually not a good idea but it is safe
1933- // here because the pointer operand is being replaced with another
1934- // pointer operand so the opcode doesn't need to change.
1935- return replaceOperand (CI, 0 , GEP->getOperand (0 ));
1936- }
1937- }
1938-
1939- return commonCastTransforms (CI);
1940- }
1941-
19421919Instruction *InstCombinerImpl::visitPtrToInt (PtrToIntInst &CI) {
19431920 // If the destination integer type is not the intptr_t type for this target,
19441921 // do a ptrtoint to intptr_t then do a trunc or zext. This allows the cast
@@ -1980,7 +1957,7 @@ Instruction *InstCombinerImpl::visitPtrToInt(PtrToIntInst &CI) {
19801957 return InsertElementInst::Create (Vec, NewCast, Index);
19811958 }
19821959
1983- return commonPointerCastTransforms (CI);
1960+ return commonCastTransforms (CI);
19841961}
19851962
19861963// / This input value (which is known to have vector type) is being zero extended
@@ -2702,11 +2679,9 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst &CI) {
27022679 if (Instruction *I = foldBitCastSelect (CI, Builder))
27032680 return I;
27042681
2705- if (SrcTy->isPointerTy ())
2706- return commonPointerCastTransforms (CI);
27072682 return commonCastTransforms (CI);
27082683}
27092684
27102685Instruction *InstCombinerImpl::visitAddrSpaceCast (AddrSpaceCastInst &CI) {
2711- return commonPointerCastTransforms (CI);
2686+ return commonCastTransforms (CI);
27122687}
0 commit comments