Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions encoder/data_processing.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func (e *Encoder) encodeOperand2(cond, opcode, rn, rd, sBit uint32, operand stri
} else if opcode == opCMP {
// If CMP fails, try converting to CMN with negated value
// CMP Rn, #imm -> CMN Rn, #-imm
// #nosec G115 - intentional overflow for two's complement negation
negatedValue := uint32(-int32(value))
// Two's complement negation in uint32 domain (avoids narrowing cast)
negatedValue := ^value + 1
if negatedEncoded, negatedOk := e.encodeImmediate(negatedValue); negatedOk {
// Use CMN instead of CMP
opcode = opCMN
Expand All @@ -258,8 +258,8 @@ func (e *Encoder) encodeOperand2(cond, opcode, rn, rd, sBit uint32, operand stri
} else if opcode == opCMN {
// If CMN fails, try converting to CMP with negated value
// CMN Rn, #imm -> CMP Rn, #-imm
// #nosec G115 - intentional overflow for two's complement negation
negatedValue := uint32(-int32(value))
// Two's complement negation in uint32 domain (avoids narrowing cast)
negatedValue := ^value + 1
if negatedEncoded, negatedOk := e.encodeImmediate(negatedValue); negatedOk {
// Use CMP instead of CMN
opcode = opCMP
Expand Down
Loading