Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/IR/Instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,7 @@ unsigned CastInst::isEliminableCastPair(
// FPTRUNC > FloatPt n/a FloatPt n/a
// FPEXT < FloatPt n/a FloatPt n/a
// PTRTOINT n/a Pointer n/a Integral Unsigned
// PTRTOADDR n/a Pointer n/a Integral Unsigned
// INTTOPTR n/a Integral Unsigned Pointer n/a
// BITCAST = FirstClass n/a FirstClass n/a
// ADDRSPCST n/a Pointer n/a Pointer n/a
Expand Down Expand Up @@ -2878,7 +2879,7 @@ unsigned CastInst::isEliminableCastPair(
{ 99,99,99, 2, 2,99,99, 8, 2,99,99,99, 4, 0}, // FPExt |
{ 1, 0, 0,99,99, 0, 0,99,99,99,99, 7, 3, 0}, // PtrToInt |
{ 1, 0, 0,99,99, 0, 0,99,99,99,99, 0, 3, 0}, // PtrToAddr |
{ 99,99,99,99,99,99,99,99,99,11,99,99,15, 0}, // IntToPtr |
{ 99,99,99,99,99,99,99,99,99,11,11,99,15, 0}, // IntToPtr |
{ 5, 5, 5, 0, 0, 5, 5, 0, 0,16,16, 5, 1,14}, // BitCast |
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,13,12}, // AddrSpaceCast -+
};
Expand Down Expand Up @@ -2972,7 +2973,8 @@ unsigned CastInst::isEliminableCastPair(
// zext, sext -> zext, because sext can't sign extend after zext
return Instruction::ZExt;
case 11: {
// inttoptr, ptrtoint -> bitcast if SrcSize<=PtrSize and SrcSize==DstSize
// inttoptr, ptrtoint/ptrtoaddr -> bitcast if SrcSize<=PtrSize and
// SrcSize==DstSize
if (!MidIntPtrTy)
return 0;
unsigned PtrSize = MidIntPtrTy->getScalarSizeInBits();
Expand Down
14 changes: 14 additions & 0 deletions llvm/test/Transforms/InstCombine/constant-expr-datalayout.ll
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,17 @@ define i64 @OpenFilter(i64 %x) {
%r = zext i8 %t to i64
ret i64 %r
}

define i64 @ptr2addr1() {
; CHECK-LABEL: @ptr2addr1(
; CHECK-NEXT: ret i64 1
;
ret i64 ptrtoaddr (ptr getelementptr (i8, ptr null, i64 1) to i64)
}

define i64 @ptr2addr2() {
; CHECK-LABEL: @ptr2addr2(
; CHECK-NEXT: ret i64 123
;
ret i64 ptrtoaddr (ptr inttoptr (i64 123 to ptr) to i64)
}