From a6f53fe4dceca59baf8036bb0a265072ccb6689f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 14 May 2023 11:37:36 -0700 Subject: [PATCH] [MC][X86] Fix != result for two register operands Fixes: 05b589101e7dadce267881e5b0832882f95a9908 (D47545) --- llvm/lib/MC/MCExpr.cpp | 2 +- llvm/test/MC/X86/{pr37425.s => register-assignment.s} | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) rename llvm/test/MC/X86/{pr37425.s => register-assignment.s} (73%) diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index 04682fd..210ed0f 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -892,7 +892,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, Res = MCValue::get(L->isEqualTo(R) ? -1 : 0); return true; case MCBinaryExpr::NE: - Res = MCValue::get(R->isEqualTo(R) ? 0 : -1); + Res = MCValue::get(L->isEqualTo(R) ? 0 : -1); return true; default: break; diff --git a/llvm/test/MC/X86/pr37425.s b/llvm/test/MC/X86/register-assignment.s similarity index 73% rename from llvm/test/MC/X86/pr37425.s rename to llvm/test/MC/X86/register-assignment.s index 2cfa5e9..84ea062 100644 --- a/llvm/test/MC/X86/pr37425.s +++ b/llvm/test/MC/X86/register-assignment.s @@ -17,4 +17,11 @@ xorq var_xdata, var_xdata .byte 2 .endif - +// CHECK: .byte 1 +.if var_xdata != %rcx + .byte 0 +.elseif var_xdata != %rax + .byte 1 +.else + .byte 2 +.endif -- 2.7.4