Skip to content

Commit 885d2e4

Browse files
committed
[NVPTXAsmPrinter] Avoid use of ConstantExpr::getIntegerCast() (NFC)
Sync the implementation with the original AsmPrinter code.
1 parent 00bfef2 commit 885d2e4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,9 +2024,12 @@ NVPTXAsmPrinter::lowerConstantForGV(const Constant *CV, bool ProcessingGeneric)
20242024
// Handle casts to pointers by changing them into casts to the appropriate
20252025
// integer type. This promotes constant folding and simplifies this code.
20262026
Constant *Op = CE->getOperand(0);
2027-
Op = ConstantExpr::getIntegerCast(Op, DL.getIntPtrType(CV->getType()),
2028-
false/*ZExt*/);
2029-
return lowerConstantForGV(Op, ProcessingGeneric);
2027+
Op = ConstantFoldIntegerCast(Op, DL.getIntPtrType(CV->getType()),
2028+
/*IsSigned*/ false, DL);
2029+
if (Op)
2030+
return lowerConstantForGV(Op, ProcessingGeneric);
2031+
2032+
break; // Error
20302033
}
20312034

20322035
case Instruction::PtrToInt: {

0 commit comments

Comments
 (0)