[ARMv6][DFG] ARM MacroAssembler is always emitting cmn when immediate is 0
authorticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jun 2017 00:50:23 +0000 (00:50 +0000)
committerticaiolima@gmail.com <ticaiolima@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jun 2017 00:50:23 +0000 (00:50 +0000)
commit71b88fb452d44680aeab166ff24bb476ff4980d3
treed2857e42d81f9f8b9e90bb6ae3a0ef917f69b105
parent340e42aae156e098bee01bdc27172b840032d65b
[ARMv6][DFG] ARM MacroAssembler is always emitting cmn when immediate is 0
https://bugs.webkit.org/show_bug.cgi?id=172972

Reviewed by Mark Lam.

We are changing internalCompare32 implementation in ARM
MacroAssembler to emit "cmp" when the "right.value" is 0.
It is generating wrong comparison cases, since the
semantics of cmn is opposite of cmp[1]. One case that it's breaking is
"branch32(MacroAssembler::Above, gpr, TrustedImm32(0))", where ends
resulting in following assembly code:

```
cmn $r0, #0
bhi <address>
```

However, as cmn is similar to "adds", it will never take the branch
when $r0 > 0. In that case, the correct opcode is "cmp". With this
patch we will fix current broken tests that uses
"branch32(MacroAssembler::Above, gpr, TrustedImm32(0))",
such as ForwardVarargs, Spread and GetRestLength.

[1] - http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0204j/Cihiddid.html

* assembler/MacroAssemblerARM.h:
(JSC::MacroAssemblerARM::internalCompare32):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218519 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/MacroAssemblerARM.h