Index: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -2231,7 +2231,10 @@ // We can emit the pointer value into this slot if the slot is an // integer slot equal to the size of the pointer. - if (DL.getTypeAllocSize(Ty) == DL.getTypeAllocSize(Op->getType())) + // + // If the pointer is larger than the resultant integer, then + // as with Trunc just depend on the assembler to truncate it. + if (DL.getTypeAllocSize(Ty) <= DL.getTypeAllocSize(Op->getType())) return OpExpr; // Otherwise the pointer is smaller than the resultant integer, mask off Index: llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll =================================================================== --- llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll +++ llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll @@ -0,0 +1,6 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s + +@ptr = external global i8, align 1 +@ref = constant i32 ptrtoint (i8* @ptr to i32), align 4 + +; CHECK: .long ptr{{$}}