This is the corresponding llvm change to D28037 to ensure no performance
regression.
Details
Diff Detail
- Build Status
Buildable 2626 Build 2626: arc lint + arc unit
Event Timeline
llvm/lib/Target/PowerPC/PPCISelLowering.h | ||
---|---|---|
999 | I don't think this is the case with every shift instruction. Please see the test case below. | |
llvm/test/CodeGen/PowerPC/shift_mask.ll | ||
27 | The results before and after when 31 < b < 64 are different. I don't think this is a safe transformation in this case. The reason being that as the ISA states:
|
Only optimize legal instructions.
I feel like needing a separate patch to add some test cases for illegal vector instructions (that get lowered to scalar instructions), and those shouldn't be combined. I need to investigate how to make those instructions illegal.
llvm/lib/Target/PowerPC/PPCISelLowering.h | ||
---|---|---|
1004 | I think this will exclude the scalar versions as well as any that will be scalarized. However, it'll also exclude versions that will be legalized in different ways (i.e. without scalarization). Wouldn't we want something that more closely reflects what we are looking for (i.e. the type will remain a vector after legalization)? Perhaps something along the lines of: Index: lib/Target/PowerPC/PPCISelLowering.h =================================================================== --- lib/Target/PowerPC/PPCISelLowering.h (revision 290968) +++ lib/Target/PowerPC/PPCISelLowering.h (working copy) @@ -996,6 +996,14 @@ namespace llvm { SDValue combineElementTruncationToVectorTruncation(SDNode *N, DAGCombinerInfo &DCI) const; + + bool supportsModuloShift(ISD::NodeType Inst, EVT ReturnType, + const SelectionDAG &DAG) const override { + assert((Inst == ISD::SHL || Inst == ISD::SRA || Inst == ISD::SRL) && + "Expect a shift instruction"); + EVT LegalizedType = getTypeToTransformTo(*DAG.getContext(), ReturnType); + return isOperationLegal(Inst, LegalizedType) && LegalizedType.isVector(); + } }; namespace PPC { |
llvm/lib/Target/PowerPC/PPCISelLowering.h | ||
---|---|---|
1004 |
Let's say isOperationLegal(Inst, LegalizedType) && LegalizedType.isVector(); is true, and we do the combine. However, later Inst turns into Inst' during the legalization, where Inst' might be any instruction that carries no modulo semantic. Won't that be a mis-combine? |
llvm/lib/Target/PowerPC/PPCISelLowering.h | ||
---|---|---|
1004 | I'm not sure I follow why the node would be transformed to something else if type legalization will legalize the type to LegalizedType and we've already determined that the operation is legal. In any case, it seems like we might want to run this combine only after legalization. I think that in that case, we'd get the semantics we're after. And I think it makes sense for other targets too as the target may not be able to definitively say whether it supports modulo shift semantics until it knows everything about the operation and type. |
Move the legalization check to the caller sides.
llvm/lib/Target/PowerPC/PPCISelLowering.h | ||
---|---|---|
1004 | Agreed. I move the legalization check to the caller sides. |
I don't think this is the case with every shift instruction. Please see the test case below.