From 64926be8475ae5f3016a9f5371a72d0943da267b Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 31 Aug 2009 19:13:47 +0000 Subject: [PATCH] Avoid unnecessary +0 in experimental-asm-printer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80603 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 2058d7d0a05..a9b89e8ad48 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -802,9 +802,10 @@ MCOperand X86ATTAsmPrinter::LowerGlobalAddressOperand(const MachineOperand &MO){ Expr = MCBinaryExpr::CreateSub(Expr, MCSymbolRefExpr::Create(NegatedSymbol, OutContext), OutContext); - Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(MO.getOffset(), - OutContext), - OutContext); + if (MO.getOffset()) + Expr = MCBinaryExpr::CreateAdd(Expr, MCConstantExpr::Create(MO.getOffset(), + OutContext), + OutContext); return MCOperand::CreateExpr(Expr); } @@ -819,10 +820,12 @@ LowerExternalSymbolOperand(const MachineOperand &MO){ MCSymbol *Sym = OutContext.GetOrCreateSymbol(Name); // FIXME: We would like an efficient form for this, so we don't have to do a // lot of extra uniquing. - const MCExpr *Expr = - MCBinaryExpr::CreateAdd(MCSymbolRefExpr::Create(Sym, OutContext), - MCConstantExpr::Create(MO.getOffset(),OutContext), - OutContext); + const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, OutContext); + if (MO.getOffset()) + Expr = MCBinaryExpr::CreateAdd(Expr, + MCConstantExpr::Create(MO.getOffset(), + OutContext), + OutContext); return MCOperand::CreateExpr(Expr); }