You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the __atomic_fetch_min and __atomic_fetch_max compiler builtins it is possible to generate instructions introduced in mips4 despite compiling for mips2. Following the code below compiling with -mips2, using __atomic_fetch_min generates a movz instruction while __atomic_fetch_max generates a movn instruction.
Here is C code that demonstrates this problem along with a Godbolt link demonstrating this miscompilation.
intmin(int*x, inty) {
return__atomic_fetch_min(x, y, __ATOMIC_SEQ_CST);
}
intmax(int*x, inty) {
return__atomic_fetch_max(x, y, __ATOMIC_SEQ_CST);
}
Expected Behavior
I would expect that instructions like movz and movn would not be emitted when compiling for -mips2 since these instructions were introduced in MIPS IV, they are not present in the MIPS II standard.