[llvm] [llvm][InstCombine] bitcast bfloat half castpair bug (PR #79832)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 02:46:43 PST 2024
================
@@ -3214,6 +3214,13 @@ unsigned CastInst::isEliminableCastPair(
return secondOp;
return 0;
case 6:
+ // In cast pairs bfloat and half float shouldn't be treated as equivalent
+ // if the first operation is a bitcast i.e. if we have
+ // bitcast bfloat to half + fpext half to double we shouldn't reduce to
+ // fpext bfloat to double as this isn't equal to fpext half to double.
+ // This has been generalised for all float pairs that have the same width.
+ if (SrcTy->getPrimitiveSizeInBits() == MidTy->getPrimitiveSizeInBits())
----------------
ostannard wrote:
This case is only reached when the first operation is a bitcast, so this condition will always be true. This optimisation should still be valid if SrcTy and MidTy are identical, but I don't know if this code would be reached in that case, or if no-op casts like that are handled elsewhere.
https://github.com/llvm/llvm-project/pull/79832
More information about the llvm-commits
mailing list