llvm.org GIT mirror llvm / 97e15a8
[X86] Selectively mark the FMA variants inside a family as isCommutable. Given a FMA family (e.g., 213, 231), not all the variants (i.e., register or memory) are commutable. E.g., for the 213 family (with the syntax src1, src2, src3): fmaXXX213 A, B, reg3/mem3 == fmaXXX213 B, A, reg3/mem3 Now consider the 231 family: fmaXXX231 A, B, reg3 == fmaXXX231 A, reg3, B But fmaXXX231 A, B, mem3 != fmaXXX231 A, mem3, B Indeed, mem3 cannot be the second argument of the memory variant of fmaXXX231. Working on a reduced test case! <rdar://problem/16800495> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208252 91177308-0d34-0410-b5e6-96231b3b80d8 Quentin Colombet 6 years ago
1 changed file(s) with 34 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
1818 multiclass fma3p_rm opc, string OpcodeStr,
1919 PatFrag MemFrag128, PatFrag MemFrag256,
2020 ValueType OpVT128, ValueType OpVT256,
21 bit IsRVariantCommutable = 0, bit IsMVariantCommutable = 0,
2122 SDPatternOperator Op = null_frag> {
22 let usesCustomInserter = 1 in
23 let usesCustomInserter = 1, isCommutable = IsRVariantCommutable in
2324 def r : FMA3
2425 (ins VR128:$src1, VR128:$src2, VR128:$src3),
2526 !strconcat(OpcodeStr,
2728 [(set VR128:$dst, (OpVT128 (Op VR128:$src2,
2829 VR128:$src1, VR128:$src3)))]>;
2930
30 let mayLoad = 1 in
31 let mayLoad = 1, isCommutable = IsMVariantCommutable in
3132 def m : FMA3
3233 (ins VR128:$src1, VR128:$src2, f128mem:$src3),
3334 !strconcat(OpcodeStr,
3536 [(set VR128:$dst, (OpVT128 (Op VR128:$src2, VR128:$src1,
3637 (MemFrag128 addr:$src3))))]>;
3738
38 let usesCustomInserter = 1 in
39 let usesCustomInserter = 1, isCommutable = IsRVariantCommutable in
3940 def rY : FMA3
4041 (ins VR256:$src1, VR256:$src2, VR256:$src3),
4142 !strconcat(OpcodeStr,
4344 [(set VR256:$dst, (OpVT256 (Op VR256:$src2, VR256:$src1,
4445 VR256:$src3)))]>, VEX_L;
4546
46 let mayLoad = 1 in
47 let mayLoad = 1, isCommutable = IsMVariantCommutable in
4748 def mY : FMA3
4849 (ins VR256:$src1, VR256:$src2, f256mem:$src3),
4950 !strconcat(OpcodeStr,
5859 string OpcodeStr, string PackTy,
5960 PatFrag MemFrag128, PatFrag MemFrag256,
6061 SDNode Op, ValueType OpTy128, ValueType OpTy256> {
61 let isCommutable = 1 in
62 // For 213, both the register and memory variant are commutable.
63 // Indeed, the commutable operands are 1 and 2 and both live in registers
64 // for both variants.
6265 defm r213 : fma3p_rm
6366 !strconcat(OpcodeStr, "213", PackTy),
64 MemFrag128, MemFrag256, OpTy128, OpTy256, Op>;
67 MemFrag128, MemFrag256, OpTy128, OpTy256,
68 /* IsRVariantCommutable */ 1,
69 /* IsMVariantCommutable */ 1,
70 Op>;
6571 let neverHasSideEffects = 1 in {
6672 defm r132 : fma3p_rm
6773 !strconcat(OpcodeStr, "132", PackTy),
6874 MemFrag128, MemFrag256, OpTy128, OpTy256>;
69 let isCommutable = 1 in
75 // For 231, only the register variant is commutable.
76 // For the memory variant the folded operand must be in 3. Thus,
77 // in that case, it cannot be swapped with 2.
7078 defm r231 : fma3p_rm
7179 !strconcat(OpcodeStr, "231", PackTy),
72 MemFrag128, MemFrag256, OpTy128, OpTy256>;
80 MemFrag128, MemFrag256, OpTy128, OpTy256,
81 /* IsRVariantCommutable */ 1,
82 /* IsMVariantCommutable */ 0>;
7383 } // neverHasSideEffects = 1
7484 }
7585
118128 let Constraints = "$src1 = $dst" in {
119129 multiclass fma3s_rm opc, string OpcodeStr, X86MemOperand x86memop,
120130 RegisterClass RC, ValueType OpVT, PatFrag mem_frag,
131 bit IsRVariantCommutable = 0, bit IsMVariantCommutable = 0,
121132 SDPatternOperator OpNode = null_frag> {
122 let usesCustomInserter = 1 in
133 let usesCustomInserter = 1, isCommutable = IsRVariantCommutable in
123134 def r : FMA3
124135 (ins RC:$src1, RC:$src2, RC:$src3),
125136 !strconcat(OpcodeStr,
127138 [(set RC:$dst,
128139 (OpVT (OpNode RC:$src2, RC:$src1, RC:$src3)))]>;
129140
130 let mayLoad = 1 in
141 let mayLoad = 1, isCommutable = IsMVariantCommutable in
131142 def m : FMA3
132143 (ins RC:$src1, RC:$src2, x86memop:$src3),
133144 !strconcat(OpcodeStr,
146157 let neverHasSideEffects = 1 in {
147158 defm r132 : fma3s_rm
148159 x86memop, RC, OpVT, mem_frag>;
149 let isCommutable = 1 in
160 // See the other defm of r231 for the explanation regarding the
161 // commutable flags.
150162 defm r231 : fma3s_rm
151 x86memop, RC, OpVT, mem_frag>;
152 }
153
154 let isCommutable = 1 in
163 x86memop, RC, OpVT, mem_frag,
164 /* IsRVariantCommutable */ 1,
165 /* IsMVariantCommutable */ 0>;
166 }
167
168 // See the other defm of r213 for the explanation regarding the
169 // commutable flags.
155170 defm r213 : fma3s_rm
156 x86memop, RC, OpVT, mem_frag, OpNode>;
171 x86memop, RC, OpVT, mem_frag,
172 /* IsRVariantCommutable */ 1,
173 /* IsMVariantCommutable */ 1,
174 OpNode>;
157175 }
158176
159177 multiclass fma3s opc132, bits<8> opc213, bits<8> opc231,