I asked AI to port the device libs reference implementation. It mostly worked, though it got the compares wrong and also missed a fold that happened in compiler. With that fixed I get identical DAG output, and almost the same globalisel output (differing by an inverted compare and select). Also adjusted some stylistic choices.