[MC][X86] Fix != result for two register operands
authorFangrui Song <i@maskray.me>
Sun, 14 May 2023 18:37:36 +0000 (11:37 -0700)
committerFangrui Song <i@maskray.me>
Sun, 14 May 2023 18:37:36 +0000 (11:37 -0700)
Fixes: 05b589101e7dadce267881e5b0832882f95a9908 (D47545)

llvm/lib/MC/MCExpr.cpp
llvm/test/MC/X86/register-assignment.s [moved from llvm/test/MC/X86/pr37425.s with 73% similarity]

index 04682fd..210ed0f 100644 (file)
@@ -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;
similarity index 73%
rename from llvm/test/MC/X86/pr37425.s
rename to llvm/test/MC/X86/register-assignment.s
index 2cfa5e9..84ea062 100644 (file)
@@ -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