Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Feb 15, 2025
1 parent 79891a0 commit 6629a40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
let trunc = self.trunc(val, dest_ty);
if llvm_util::get_version() >= (19, 0, 0) {
unsafe {
if llvm::LLVMIsATruncInst(trunc).is_some() {
if llvm::LLVMIsAInstruction(trunc).is_some() {
llvm::LLVMSetNUW(trunc, True);
}
}
Expand All @@ -914,7 +914,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
let trunc = self.trunc(val, dest_ty);
if llvm_util::get_version() >= (19, 0, 0) {
unsafe {
if llvm::LLVMIsATruncInst(trunc).is_some() {
if llvm::LLVMIsAInstruction(trunc).is_some() {
llvm::LLVMSetNSW(trunc, True);
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,6 @@ unsafe extern "C" {

// Operations on instructions
pub(crate) fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
pub(crate) fn LLVMIsATruncInst(Val: &Value) -> Option<&Value>;
pub(crate) fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
pub(crate) fn LLVMGetOperand(Val: &Value, Index: c_uint) -> Option<&Value>;

Expand Down
6 changes: 3 additions & 3 deletions tests/codegen/unchecked_shifts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ pub unsafe fn unchecked_shl_unsigned_same(a: u32, b: u32) -> u32 {
#[no_mangle]
pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 {
// CHECK-NOT: assume
// LLVM18-DAG: %[[TRUNC:.+]] = trunc i32 %b to i16
// LLVM19PLUS-DAG: %[[TRUNC:.+]] = trunc nuw i32 %b to i16
// CHECK-DAG: shl i16 %a, %[[TRUNC]]
// LLVM18: %[[TRUNC:.+]] = trunc i32 %b to i16
// LLVM19PLUS: %[[TRUNC:.+]] = trunc nuw i32 %b to i16
// CHECK: shl i16 %a, %[[TRUNC]]
a.unchecked_shl(b)
}

Expand Down

0 comments on commit 6629a40

Please sign in to comment.