Skip to content

Conversation

@xeren
Copy link
Collaborator

@xeren xeren commented Feb 13, 2026

Adds signed and unsigned integer maximum and minimum as binary operations. Adds support for respective atomic operations in LLVM IR.

@hernanponcedeleon
Copy link
Owner

We should also be able to simplify much of the code from #937, right?

@ThomasHaas
Copy link
Collaborator

ThomasHaas commented Feb 13, 2026

I don't think there is much code on #937 to be simplified, is there? It looks like you would only replace some ITE(LTE(..), .., ..) construct with a single operator but that's it.

Btw. I think a better long-term solution would actually be to have "Expressions with holes" and then instead of generating an RMWOp with some (op, operand)-pair you would just provide the expression. Then we don't even need ops for min/max, because you could put min(_, val) := ITE( _ < val, _, val) as RMW operation where _ gets replaced by the register you load into. Basically, an RMWOp could compute an arbitrary expression over the loaded value instead of the handful of predefined one's.

EDIT: I just prototyped a version for LLVM_rmw_op with holes like so (taken from an IMM test)

8:       bv32 r3 = llvm_rmw_op(&x, bv32 {_} + bv32(1), REL) // amounts to fetch_add(&x, 1, REL)

I think it is certainly feasible and would could unify a lot. It would also cover Xchg (don't add a hole), possibly any form of CAS by adding an optional cmp-expr with hole, and generally also any fancy operation we can think of in our expression system, e.g. atomic_fetch_cttz, and any atomics on floats.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants