Page MenuHomePhabricator

[AArch64][CodeGen] Restrict bfloat vector operations to what's actually supported
ClosedPublic

Authored by stuij on Aug 2 2020, 3:46 PM.

Details

Summary

Previously in addTypeForNeon, we would set the operations for bfloat vectors
like other generic types. But as bfloat is a storage-only type a number of
operations shouldn't be set. This patch fixes that.

Diff Detail

Event Timeline

stuij created this revision.Aug 2 2020, 3:46 PM
stuij requested review of this revision.Aug 2 2020, 3:47 PM

Quick question - what is the expected behaviour? Do we just never expect to see an bf16 add, and if we do it's a fatal error? Or is some form of automatic promotion expected to happen?

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1070

These are integer, so I wouldn't expect then to cause much trouble.

1091

Why not leave these as expand?

dnsampaio added inline comments.Aug 3 2020, 2:04 AM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1091

And they are integers as well, no? Perhaps the correct tests we want here is !VT.isFloatingPoint() or alike?

stuij added a comment.Aug 3 2020, 5:18 AM

Quick question - what is the expected behaviour? Do we just never expect to see an bf16 add, and if we do it's a fatal error? Or is some form of automatic promotion expected to happen?

Yes, I don't think we should see explicit bfloat adds. It's a storage type, and addition might not be what the user intended. So we should error.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1091

As I understand, as bfloat is a storage type, it should be converted explicitly to a different type if you want to do arithmetic operations. It makes sense to me to explicitly not allow this.

dmgreen added inline comments.Aug 3 2020, 2:04 PM
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
1091

The frem is the only one in this list that would make sense for bf16. I believe the default would be Legal(?) So Expand seems like a sensible enough option. At least, it would seem a little odd to specifically mark them differently for bf16. We don't do anything special for fadd/fdiv/etc as far as I understand.

stuij updated this revision to Diff 288333.Aug 27 2020, 7:56 AM

addressing review comments

dmgreen accepted this revision.Aug 27 2020, 8:59 AM

Thanks. Sounds good to me.

This revision is now accepted and ready to land.Aug 27 2020, 8:59 AM
This revision was landed with ongoing or failed builds.Aug 28 2020, 3:44 AM
This revision was automatically updated to reflect the committed changes.