[llvm] [llvm][InstCombine] bitcast bfloat half castpair bug (PR #79832)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 30 07:11:39 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->isFloatingPointTy() && MidTy->isFloatingPointTy())
+ return 0;
----------------
nikic wrote:
This implementation doesn't make much sense to me. Note that case 6 is the combination of bitcast + fptoui/fptosi/fpext/fptrunc, so you know that the MidTy is always a float. The below check also ensures that SrcTy is always a float. So this condition in the end is equivalent to "never fold". To implement that, you should replace the entries in the above table with `0` and remove this case entirely.
https://github.com/llvm/llvm-project/pull/79832
More information about the llvm-commits
mailing list