23 questions
1
vote
1
answer
79
views
How to set the register from the data from memory using the CMOVG instruction?
The problem is inside the Graphic subroutine at row 236. (4th, 13th and 16th row in sublabel .writePixel).
In this subroutine I browse the graphic pixel from 280 to 487 column and 368 to 385 row. (...
2
votes
1
answer
209
views
The Execution Order in an Assembly Algorithm that utilizes a Conditional Move Instruction
I have recently been working on an assembly algorithm for calculating the absolute difference between two long integers, and I have some concerns regarding the execution order in the presence of ...
0
votes
0
answers
100
views
Understanding fcmovb instruction in x86
I'm not understanding why fcmovb st(0) st(4) is not acting the way I expect. afaiu it will set st0 = st4 if the CF flag is set.
Before:
gdb> i r eflags st0 st4
eflags 0x282 [ SF IF ]
st0 0 (raw ...
6
votes
1
answer
649
views
In assembly, should branchless code use complementary CMOVs?
It's well known that we can use the CMOV instruction to write branchless code, but I was wondering if I'm writing the equivalent of x = cond ? 1 : 2, should I prefer
CMOVE rax, 1 #1a
CMOVNE rax, 2 ...
9
votes
2
answers
3k
views
RISCV branchless coding
On Intel AVX, there is a possibility of branchless code.
Instead of branching for case0 or case1, you can compute both cases, and blend the results based on a condition.
AVX does this 8 way for float ...
4
votes
1
answer
1k
views
In x86_64, does a 32-bit cmov clear the top bits if the condition is false?
In 64-bit mode on x86, most 32-bit arithmetic operations clear the top 32 bits of the destination register. What if the arithmetic operation is a "cmov" instruction, and the condition is ...
6
votes
2
answers
2k
views
Conditional move (cmov) for AVX vector registers based on scalar integer condition?
For 64-bit registers, there is the CMOVcc A, B instruction, that only writes B to A if condition cc is satisfied:
; Do rax <- rdx iff rcx == 0
test rcx, rcx
cmove rax, rdx
However, I wasn't able ...
3
votes
1
answer
1k
views
Conditional move zero into register?
Is there a way to conditional move a zero into a register in assembly? I'm trying to do
cmpb %r9b, %r8b #compare r9 and r8
cmovgq $0, %rcx #If r8>r9, move zero to rcx
But the compiler is ...
5
votes
1
answer
3k
views
Why does x86 only have 1 form of conditional move, not immediate or 8-bit?
I've noticed that the Conditional Move instruction is less extensible than the normal mov. For example, it doesn't support immediates and doesn't support the low-byte of a register.
Out of curiosity, ...
-1
votes
1
answer
1k
views
How to force compiler to generate conditional move by using inline assembly
I've spent several hours trying to convert the following code to inline assembly (GCC) but in vain:
int new_low = mid + 1;
int new_high = mid - 1;
if (middle < key) {
low = new_low;
}
if (!(...
1
vote
0
answers
461
views
Removing CMOV Instructions using GCC-9.2.0 (x86)
I am looking to compile a set of benchmark suites using traditional GCC optimizations (as in using -O2/3) and comparing this with the same benchmark using no cmov instructions. I have seen several ...
6
votes
2
answers
2k
views
Do all x86-64 implementations support the CMOVcc instructions?
In my answer to the question Assembly code to return smallest integer in array instead randomly returns either last or second to last number I presented an alternative using a cmovcc instruction. I ...
4
votes
1
answer
3k
views
Conditional move (cmov) in GCC compiler
I saw somewhere that the GCC compiler might prefer sometimes not using conditional mov when converting my code into ASM.
What are the cases where it might choose to do something other than ...
2
votes
1
answer
359
views
Producing a cmp and cmov instruction in V8 for x64
I am trying to implement my own version of essentially Math.clamp within V8 using the internal assembler.
I managed to produce a version of it using the Torque scripting language, and wanted to try ...
7
votes
2
answers
818
views
Hard to debug SEGV due to skipped cmov from out-of-bounds memory
I'm trying to code a few high-performance assembly functions as an exercise, and have encountered a weird segfault that happens when running the program, but not in valgrind or nemiver.
Basically a ...