When emitting comparison for fp16, in addition to promote the LHS and RHS to fp32, we need to change the VT as well.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I think the real bug here is in emitComparison, which has exactly this code to promote the arguments but still produces an f16 result. Changing that to f32 ought to fix things (though the dataflow between FCMP and FCCMP is a bit dubious, it's playing rather loose with types given that NZCV is the only register actually modified).
test/CodeGen/AArch64/half.ll | ||
---|---|---|
87–88 | There are more ways this could go wrong than simply not emitting an fcmp/fccmp. I think you should check for an fcvt producing an s register that then gets used in the comparisons. |
This fixes the crash of "llc: tip/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:6340: void llvm::SelectionDAG::ReplaceAllUsesWith(llvm::SDNode *, llvm::SDNode *): Assertion `(!From->hasAnyUseOfValue(i) || From->getValueType(i) == To->getValueType(i)) && "Cannot use this version of ReplaceAllUsesWith!"' failed.
Thank you, Tim! And do we need to guard the promotion of fp16->fp32 with !HasFullFP16() check? If some subtarget has full fp16 support, the promotion is not needed, is it?
lib/Target/AArch64/AArch64ISelLowering.cpp | ||
---|---|---|
1412 | Operands get from a chained SETCC |
llvm/trunk/test/CodeGen/AArch64/half.ll | ||
---|---|---|
86 ↗ | (On Diff #56847) | It would be good to follow the convention of having a space between ; and CHECK (see other instances in this file): |
Operands get from a chained SETCC