Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7024,18 +7024,22 @@ case NVPTX::BI__nvvm_atom_max_gen_i: case NVPTX::BI__nvvm_atom_max_gen_l: case NVPTX::BI__nvvm_atom_max_gen_ll: + return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Max, E); + case NVPTX::BI__nvvm_atom_max_gen_ui: case NVPTX::BI__nvvm_atom_max_gen_ul: case NVPTX::BI__nvvm_atom_max_gen_ull: - return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Max, E); + return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::UMax, E); case NVPTX::BI__nvvm_atom_min_gen_i: case NVPTX::BI__nvvm_atom_min_gen_l: case NVPTX::BI__nvvm_atom_min_gen_ll: + return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Min, E); + case NVPTX::BI__nvvm_atom_min_gen_ui: case NVPTX::BI__nvvm_atom_min_gen_ul: case NVPTX::BI__nvvm_atom_min_gen_ull: - return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::Min, E); + return MakeBinaryAtomicValue(*this, llvm::AtomicRMWInst::UMin, E); case NVPTX::BI__nvvm_atom_cas_gen_i: case NVPTX::BI__nvvm_atom_cas_gen_l: Index: test/CodeGen/builtins-nvptx.c =================================================================== --- test/CodeGen/builtins-nvptx.c +++ test/CodeGen/builtins-nvptx.c @@ -234,30 +234,30 @@ // CHECK: atomicrmw xchg __nvvm_atom_xchg_gen_ll(&sll, ll); - // CHECK: atomicrmw max + // CHECK: atomicrmw max i32* __nvvm_atom_max_gen_i(ip, i); - // CHECK: atomicrmw max + // CHECK: atomicrmw umax i32* __nvvm_atom_max_gen_ui((unsigned int *)ip, i); // CHECK: atomicrmw max __nvvm_atom_max_gen_l(&dl, l); - // CHECK: atomicrmw max + // CHECK: atomicrmw umax __nvvm_atom_max_gen_ul((unsigned long *)&dl, l); - // CHECK: atomicrmw max + // CHECK: atomicrmw max i64* __nvvm_atom_max_gen_ll(&sll, ll); - // CHECK: atomicrmw max + // CHECK: atomicrmw umax i64* __nvvm_atom_max_gen_ull((unsigned long long *)&sll, ll); - // CHECK: atomicrmw min + // CHECK: atomicrmw min i32* __nvvm_atom_min_gen_i(ip, i); - // CHECK: atomicrmw min + // CHECK: atomicrmw umin i32* __nvvm_atom_min_gen_ui((unsigned int *)ip, i); // CHECK: atomicrmw min __nvvm_atom_min_gen_l(&dl, l); - // CHECK: atomicrmw min + // CHECK: atomicrmw umin __nvvm_atom_min_gen_ul((unsigned long *)&dl, l); - // CHECK: atomicrmw min + // CHECK: atomicrmw min i64* __nvvm_atom_min_gen_ll(&sll, ll); - // CHECK: atomicrmw min + // CHECK: atomicrmw umin i64* __nvvm_atom_min_gen_ull((unsigned long long *)&sll, ll); // CHECK: cmpxchg