Auto merge of #103299 - nikic:usub-overflow, r=wesleywiser · rust-lang/rust@f42b6fa (original) (raw)
`@@ -365,11 +365,14 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
`
365
365
`Int(I64) => "llvm.ssub.with.overflow.i64",
`
366
366
`Int(I128) => "llvm.ssub.with.overflow.i128",
`
367
367
``
368
``
`-
Uint(U8) => "llvm.usub.with.overflow.i8",
`
369
``
`-
Uint(U16) => "llvm.usub.with.overflow.i16",
`
370
``
`-
Uint(U32) => "llvm.usub.with.overflow.i32",
`
371
``
`-
Uint(U64) => "llvm.usub.with.overflow.i64",
`
372
``
`-
Uint(U128) => "llvm.usub.with.overflow.i128",
`
``
368
`+
Uint(_) => {
`
``
369
`+
// Emit sub and icmp instead of llvm.usub.with.overflow. LLVM considers these
`
``
370
`+
// to be the canonical form. It will attempt to reform llvm.usub.with.overflow
`
``
371
`+
// in the backend if profitable.
`
``
372
`+
let sub = self.sub(lhs, rhs);
`
``
373
`+
let cmp = self.icmp(IntPredicate::IntULT, lhs, rhs);
`
``
374
`+
return (sub, cmp);
`
``
375
`+
}
`
373
376
``
374
377
` _ => unreachable!(),
`
375
378
`},
`