- Introduction of mask scalar TableGen patterns.
- Introduction of new scalar move TableGen patterns and refactoring of existing ones.
- Folding of pattern created by introducing scalar masking in Clang header files.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
32068 ↗ | (On Diff #147298) | use cast not dyn_cast |
Is it possible to add tests for any patterns that are new? It's not good to add untested code.
Yes we could, but only for X86ISelLowering folding and FMA patterns - the other ones are multiclasses without any definitions, so they never alter anything at this point. They are intended to be a basis for several upcoming patches which will add defms for these patterns with the tests alongside them. I'm OOO tomorrow so I'll be able to add the tests for first two cases on Monday.
Just commit the test files to trunk with the current codegen. No need for a phabricator review. Then rebase this patch to show the diff with the new codegen
Test diffs are now visible.
Note: there is no test for div in combine-select.ll - div pattern gets split into 3 basic block with a branch condition, so this optimization doesn't apply to it.
lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
32216 ↗ | (On Diff #147844) | I don't know if you can use ISD::SELECT here if you don't have the ANDing with 1. ISD::SELECT definition is that the condition value is either 0 or 1 regardless of how many bits it is. If you pass in the raw X you violate this rule. |
lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
32216 ↗ | (On Diff #147844) | I think I can - X86TargetLowering::LowerSELECT takes care of that when operands are scalar and subtarget has AVX512 which is always the case here. I'm talking about this code: // AVX512 fallback is to lower selects of scalar floats to masked moves. if ((VT == MVT::f64 || VT == MVT::f32) && Subtarget.hasAVX512()) { SDValue Cmp = DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, MVT::v1i1, Cond); return DAG.getNode(X86ISD::SELECTS, DL, VT, Cmp, Op1, Op2); } |
It's not really a question of whether it will be lowered correctly. Target independent DAG combines call getBooleanContents and expect that the condition for a target independent ISD:;SELECT node obey that.
lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
32208 ↗ | (On Diff #147844) | This isScalarInteger check is unnecessary, ConstantSDNodes can only be scalar, and the condition for an ISD::SELECT can only be scalar which means the AND would have to be scalar. |
32213 ↗ | (On Diff #147844) | The tests all pass if I change this line to SDValue Mask = AndNode; We have a later combine that removes the mask once we've converted to v1i1. |
lib/Target/X86/X86ISelLowering.cpp | ||
---|---|---|
32207 ↗ | (On Diff #148575) | You might still need a truncate on the AND if it isn't an i8 |
lib/Target/X86/X86InstrFMA.td | ||
369 ↗ | (On Diff #148575) | This should be [HasFMA, NoAVX512]. And the AVX512InstrInfo.td needs an equivalent set of patterns mapped to the unmasked EVEX instructions. |