diff options
| author | Ben Kimock <kimockb@gmail.com> | 2025-08-13 14:38:06 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-13 14:38:06 +0000 |
| commit | fa41e9b47348171862773b70eaca70a0ff240963 (patch) | |
| tree | 8e9d89a9f0653b4e19f4c55fdfda10952f36992b /compiler/rustc_codegen_llvm/src | |
| parent | 85c8d7089035d60c63a0594b07ff48981399f2ed (diff) | |
| parent | 4b5f667dc4984ca65c74f68f16d094fc5e9749f7 (diff) | |
| download | rust-fa41e9b47348171862773b70eaca70a0ff240963.tar.gz rust-fa41e9b47348171862773b70eaca70a0ff240963.zip | |
Merge pull request #4525 from rust-lang/rustup-2025-08-13
Automatic Rustup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/builder.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index 32cdef075e7..917d07e3c61 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -557,13 +557,25 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { let (size, signed) = ty.int_size_and_signed(self.tcx); let width = size.bits(); - if oop == OverflowOp::Sub && !signed { - // Emit sub and icmp instead of llvm.usub.with.overflow. LLVM considers these - // to be the canonical form. It will attempt to reform llvm.usub.with.overflow - // in the backend if profitable. - let sub = self.sub(lhs, rhs); - let cmp = self.icmp(IntPredicate::IntULT, lhs, rhs); - return (sub, cmp); + if !signed { + match oop { + OverflowOp::Sub => { + // Emit sub and icmp instead of llvm.usub.with.overflow. LLVM considers these + // to be the canonical form. It will attempt to reform llvm.usub.with.overflow + // in the backend if profitable. + let sub = self.sub(lhs, rhs); + let cmp = self.icmp(IntPredicate::IntULT, lhs, rhs); + return (sub, cmp); + } + OverflowOp::Add => { + // Like with sub above, using icmp is the preferred form. See + // <https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60uadd.2Ewith.2Eoverflow.60.20.28again.29/near/533041085> + let add = self.add(lhs, rhs); + let cmp = self.icmp(IntPredicate::IntULT, add, lhs); + return (add, cmp); + } + OverflowOp::Mul => {} + } } let oop_str = match oop { |
