[llvm] a6f53fe - [MC][X86] Fix != result for two register operands

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun May 14 11:37:41 PDT 2023


Author: Fangrui Song
Date: 2023-05-14T11:37:36-07:00
New Revision: a6f53fe4dceca59baf8036bb0a265072ccb6689f

URL: https://github.com/llvm/llvm-project/commit/a6f53fe4dceca59baf8036bb0a265072ccb6689f
DIFF: https://github.com/llvm/llvm-project/commit/a6f53fe4dceca59baf8036bb0a265072ccb6689f.diff

LOG: [MC][X86] Fix != result for two register operands

Fixes: 05b589101e7dadce267881e5b0832882f95a9908 (D47545)

Added: 
    llvm/test/MC/X86/register-assignment.s

Modified: 
    llvm/lib/MC/MCExpr.cpp

Removed: 
    llvm/test/MC/X86/pr37425.s


################################################################################
diff  --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 04682fdc7ecec..210ed0f869292 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 2cfa5e98a392c..84ea062cb746e 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


        


More information about the llvm-commits mailing list