[llvm] AMDGPU: Add tonearest and towardzero roundings for intrinsic llvm.fptrunc.round (PR #104486)
Changpeng Fang via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 21:41:16 PDT 2024
changpeng wrote:
> Yes. You just need an SDNodeXForm to modify the value
What about a rounding mode that is not supported, such as "round.tonearestaway"?
I am doing like following, but it does not show that the intrinsic can not be selected:
def as_supported_rounding_mode: SDNodeXForm<imm, [{
int RoundMode = N->getSExtValue();
if (RoundMode == (int)RoundingMode::TowardZero ||
RoundMode == (int)RoundingMode::NearestTiesToEven ||
RoundMode == (int)RoundingMode::TowardPositive ||
RoundMode == (int)RoundingMode::TowardNegative) {
unsigned HW_Mode = (RoundMode + 3) % 4;
return CurDAG->getTargetConstant(HW_Mode, SDLoc(N), MVT::i32);
}
return SDValue();
}]>;
https://github.com/llvm/llvm-project/pull/104486
More information about the llvm-commits
mailing list