-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[VectorCombine] foldShuffleOfBinops - failure to track OperandValueInfo #171934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -956,6 +956,27 @@ TargetTransformInfo::getOperandInfo(const Value *V) { | |
| return {OpInfo, OpProps}; | ||
| } | ||
|
|
||
| TargetTransformInfo::OperandValueInfo | ||
| TargetTransformInfo::mergeInfo(const Value *X, const Value *Y) { | ||
| auto [OpInfoX, OpPropsX] = TargetTransformInfo::getOperandInfo(X); | ||
| auto [OpInfoY, OpPropsY] = TargetTransformInfo::getOperandInfo(Y); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If X == Y we can just return OpInfoX/OpPropsX immediately (or we just handle this in foldShuffleOfBinops)? |
||
| OperandValueKind MergeInfo = OK_AnyValue; | ||
| OperandValueProperties MergeProp = OP_None; | ||
|
|
||
| if (OpInfoX == OK_AnyValue || OpInfoY == OK_AnyValue || | ||
| OpInfoX == OK_UniformValue || OpInfoY == OK_UniformValue) | ||
| MergeInfo = OK_AnyValue; | ||
| else if (OpInfoX == OK_NonUniformConstantValue || | ||
| OpInfoY == OK_NonUniformConstantValue) | ||
| MergeInfo = OK_NonUniformConstantValue; | ||
| else | ||
| MergeInfo = X == Y ? OK_UniformConstantValue : OK_NonUniformConstantValue; | ||
|
|
||
| MergeProp = OpPropsX == OpPropsY ? OpPropsX : OP_None; | ||
| return {MergeInfo, MergeProp}; | ||
| } | ||
|
|
||
| InstructionCost TargetTransformInfo::getArithmeticInstrCost( | ||
| unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, | ||
| OperandValueInfo Op1Info, OperandValueInfo Op2Info, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,19 @@ define <4 x float> @shuf_fdiv_v4f32_yy(<4 x float> %x, <4 x float> %y, <4 x floa | |
| ret <4 x float> %r | ||
| } | ||
|
|
||
| define <16 x i16> @shuf_uniform_shift_v16i16_v8i16(<8 x i16> %a0, <8 x i16> %a1) { | ||
| ; CHECK-LABEL: define <16 x i16> @shuf_uniform_shift_v16i16_v8i16( | ||
| ; CHECK-SAME: <8 x i16> [[A0:%.*]], <8 x i16> [[A1:%.*]]) #[[ATTR0]] { | ||
| ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x i16> [[A0]], <8 x i16> [[A1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
| ; CHECK-NEXT: [[RES:%.*]] = shl <16 x i16> [[TMP1]], splat (i16 7) | ||
| ; CHECK-NEXT: ret <16 x i16> [[RES]] | ||
| ; | ||
| %v0 = shl <8 x i16> %a0, splat (i16 7) | ||
| %v1 = shl <8 x i16> %a1, splat (i16 7) | ||
| %res = shufflevector <8 x i16> %v0, <8 x i16> %v1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15> | ||
| ret <16 x i16> %res | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need test coverage for all constant cases , pow2 cases etc. See X86TTIImpl::getArithmeticInstrCost for examples of how various operand info modes get used - multiplies are probably the easiest to work with. |
||
|
|
||
| ; Common operand is op0 of the binops. | ||
|
|
||
| define <4 x i32> @shuf_add_v4i32_xx(<4 x i32> %x, <4 x i32> %y, <4 x i32> %z) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this take OperandValueInfo inputs instead of Value? Or at least make an additional variant that the Value args version wraps around.