[WebAssembly] Use eqz to negate a branch conditions.

llvm-svn: 269681
This commit is contained in:
Dan Gohman 2016-05-16 18:59:34 +00:00
parent bf05a4589e
commit 804749c942
2 changed files with 3 additions and 10 deletions

View File

@ -106,16 +106,10 @@ bool WebAssemblyLowerBrUnless::runOnMachineFunction(MachineFunction &MF) {
// If we weren't able to invert the condition in place. Insert an
// expression to invert it.
if (!Inverted) {
unsigned ZeroReg = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
MFI.stackifyVReg(ZeroReg);
BuildMI(MBB, MI, MI->getDebugLoc(), TII.get(WebAssembly::CONST_I32),
ZeroReg)
.addImm(0);
unsigned Tmp = MRI.createVirtualRegister(&WebAssembly::I32RegClass);
MFI.stackifyVReg(Tmp);
BuildMI(MBB, MI, MI->getDebugLoc(), TII.get(WebAssembly::EQ_I32), Tmp)
.addReg(Cond)
.addReg(ZeroReg);
BuildMI(MBB, MI, MI->getDebugLoc(), TII.get(WebAssembly::EQZ_I32), Tmp)
.addReg(Cond);
Cond = Tmp;
Inverted = true;
}

View File

@ -1261,8 +1261,7 @@ bb50:
; OPT: block
; OPT: block
; OPT-NEXT: i32.const $push
; OPT-NEXT: i32.const $push
; OPT-NEXT: i32.eq $push{{.*}}=, $pop{{.*}}, $pop{{.*}}{{$}}
; OPT-NEXT: i32.eqz $push{{.*}}=, $pop{{.*}}{{$}}
; OPT-NEXT: br_if 0, $pop{{.*}}{{$}}
; OPT-NEXT: call test15_callee1@FUNCTION{{$}}
; OPT-NEXT: br 1{{$}}