@@ -1916,29 +1916,6 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
1916
1916
return nullptr ;
1917
1917
}
1918
1918
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
-
1942
1919
Instruction *InstCombinerImpl::visitPtrToInt (PtrToIntInst &CI) {
1943
1920
// If the destination integer type is not the intptr_t type for this target,
1944
1921
// 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) {
1980
1957
return InsertElementInst::Create (Vec, NewCast, Index);
1981
1958
}
1982
1959
1983
- return commonPointerCastTransforms (CI);
1960
+ return commonCastTransforms (CI);
1984
1961
}
1985
1962
1986
1963
// / This input value (which is known to have vector type) is being zero extended
@@ -2702,11 +2679,9 @@ Instruction *InstCombinerImpl::visitBitCast(BitCastInst &CI) {
2702
2679
if (Instruction *I = foldBitCastSelect (CI, Builder))
2703
2680
return I;
2704
2681
2705
- if (SrcTy->isPointerTy ())
2706
- return commonPointerCastTransforms (CI);
2707
2682
return commonCastTransforms (CI);
2708
2683
}
2709
2684
2710
2685
Instruction *InstCombinerImpl::visitAddrSpaceCast (AddrSpaceCastInst &CI) {
2711
- return commonPointerCastTransforms (CI);
2686
+ return commonCastTransforms (CI);
2712
2687
}
0 commit comments