I still think it's highly questionable that we have two intrinsics
with identical behavior and only vary by the name of the libcall used
if it happens to be lowered that way, but try to reduce the feature
delta between SDAG and GlobalISel for recently added intrinsics. I'm
not sure which opcode should be considered the canonical one, but
lower roundeven back to round.
Details
Diff Detail
Event Timeline
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | I am afraid this change breaks the semantics of roundeven. Intrinsic round implements the same operation as libm function round (http://llvm.org/docs/LangRef.html#id554). In the latest draft (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2478.pdf, 7.12.9.6p2) the function round is described: The round functions round their argument to the nearest integer value in floating-point format, rounding halfway cases away from zero, regardless of the current rounding direction. In the same draft roundeven is described (7.12.9.8p2): The roundeven functions round their argument to the nearest integer value in floating-point format, rounding halfway cases to even (that is, to the nearest value that is an even integer), regardless of the current rounding direction. round and roundeven implement different rounding modes. Both functions do not depend on the current rounding mode. LIBC variants provide roundeven but these implementations look complicated. There must be an algorithm which uses trunc and implements roundeven suitable for vector operations. Probably the algorithm that uses remainder in https://stackoverflow.com/questions/32746523/ieee-754-compliant-round-half-to-even can be used to implement roundeven similar to round in LegalizerHelper::lowerIntrinsicRound. |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2493 | typo: operatio |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | Oh right, this should have been G_FRINT. I can't keep all the rounding functions straight |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | Why not adding new target opcode, like G_FROUNDEVEN or G_INTRINSIC_ROUNDEVEN? |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | That is added, and this is where it's lowered to the other equivalent operation |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | Indeed :) |
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp | ||
---|---|---|
2494 | AMDGPU has no library calls and does have the instruction. The unconstrained FP operations are defined as running in the default FP mode. It's quite undefined to execute them in another mode, these are equivalent operations. |
The patch looks good to me, however I am not experienced in GlobalISel. Someone more familiar with it should look at this patch.
typo: operatio