summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/MC/MCParser/AsmParser.cpp2
-rw-r--r--llvm/test/MC/PowerPC/pr38945.s21
2 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index fd226eac4cd..06489622be6 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -1125,7 +1125,7 @@ bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
// semantics in the face of reassignment.
if (Sym->isVariable()) {
auto V = Sym->getVariableValue(/*SetUsed*/ false);
- bool DoInline = isa<MCConstantExpr>(V);
+ bool DoInline = isa<MCConstantExpr>(V) && !Variant;
if (auto TV = dyn_cast<MCTargetExpr>(V))
DoInline = TV->inlineAssignedExpr();
if (DoInline) {
diff --git a/llvm/test/MC/PowerPC/pr38945.s b/llvm/test/MC/PowerPC/pr38945.s
new file mode 100644
index 00000000000..6588b778771
--- /dev/null
+++ b/llvm/test/MC/PowerPC/pr38945.s
@@ -0,0 +1,21 @@
+// RUN: llvm-mc -triple=powerpc64-pc-linux %s -o - | FileCheck %s
+
+NUMBER = 0x6ffffff9
+
+ .text
+.globl main
+main:
+ cmpwi 8,(NUMBER)@l
+ cmpwi 8,-(NUMBER)@l
+ cmpwi 8,(-NUMBER)@l
+ cmpwi 8,NUMBER@l
+ cmpwi 8,-NUMBER@l
+
+
+// CHECK: main:
+// CHECK: cmpwi 8, -7
+// CHECK: cmpwi 8, 7
+// CHECK: cmpwi 8, 7
+// CHECK: cmpwi 8, -7
+// CHECK: cmpwi 8, 7
+
OpenPOWER on IntegriCloud