This is an archive of the discontinued LLVM Phabricator instance.

[globalisel][tablegen] Skip src child predicates
ClosedPublic

Authored by rovka on Nov 2 2017, 8:09 AM.

Details

Summary

The GlobalISel TableGen backend didn't check for predicates on the
source children. This caused it to generate code for ARM patterns such
as SMLABB or similar, but without properly checking for the sext_16_node
part of the operands. This in turn meant that we would select SMLABB
instead of MLA for simple sequences such as s32 + s32 * s32, which is
wrong (we want a MLA on the full operands, not just their bottom 16
bits).

This patch forces TableGen to skip patterns with predicates on the src
children, so it doesn't generate code for SMLABB and other similar ARM
instructions at all anymore. AArch64 and X86 are not affected.

Note that a more principled fix which would actually check the predicates
would require changes to ARMInstrInfo.td, since the predicate used by
SMLABB is very SelectionDAG-specific.

Diff Detail

Repository
rL LLVM

Event Timeline

rovka created this revision.Nov 2 2017, 8:09 AM
rovka added a comment.Nov 2 2017, 8:14 AM

Sorry about the indirect test, but it's a bit difficult to test directly since this is restricting functionality rather than adding it. Are we interested in having tests for failed imports? I haven't seen any, but I may have missed them...

dsanders edited edge metadata.Nov 2 2017, 11:04 AM

LGTM. This must have been missed because they're genuinely operands. A lot of the predicates (particularly those on imm and fpimm) are on operators even though they look like operands.

Sorry about the indirect test, but it's a bit difficult to test directly since this is restricting functionality rather than adding it. Are we interested in having tests for failed imports? I haven't seen any, but I may have missed them...

We don't have any at the moment but I think it makes sense to have them for PatLeaf/ComplexPattern and other things where failing to import is the right thing to do. I don't think we should add them for the cases where it's failing because we haven't implemented something yet

This revision was automatically updated to reflect the committed changes.