[WebAssembly] Reverse the order of operands for br_if
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyInstrInfo.cpp
index fe27b1ac669bdb3f2258bb6e92d92dea6263a120..ed30b535480e98b670af69c7feacd4d0dce874a1 100644 (file)
@@ -54,8 +54,8 @@ bool WebAssemblyInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,
     case WebAssembly::BR_IF:
       if (HaveCond)
         return true;
-      Cond.push_back(MI.getOperand(1));
-      TBB = MI.getOperand(0).getMBB();
+      Cond.push_back(MI.getOperand(0));
+      TBB = MI.getOperand(1).getMBB();
       HaveCond = true;
       break;
     case WebAssembly::BR:
@@ -105,8 +105,8 @@ unsigned WebAssemblyInstrInfo::InsertBranch(
   }
 
   BuildMI(&MBB, DL, get(WebAssembly::BR_IF))
-      .addMBB(TBB)
-      .addOperand(Cond[0]);
+      .addOperand(Cond[0])
+      .addMBB(TBB);
   if (!FBB)
     return 1;