forked from OSchip/llvm-project
[WebAssembly] Use eqz to negate a branch conditions.
llvm-svn: 269681
This commit is contained in:
parent
bf05a4589e
commit
804749c942
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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{{$}}
|
||||
|
|
Loading…
Reference in New Issue