<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 15, 2015, at 2:59 AM, Mehdi Amini <<a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On Jan 15, 2015, at 12:40 AM, Ahmed Bougacha <<a href="mailto:ahmed.bougacha@gmail.com" class="">ahmed.bougacha@gmail.com</a>> wrote:<br class=""><br class="">On Thu, Jan 15, 2015 at 8:42 AM, Elena Demikhovsky<br class=""><<a href="mailto:elena.demikhovsky@intel.com" class="">elena.demikhovsky@intel.com</a>> wrote:<br class=""><blockquote type="cite" class="">Hi Adam,<br class=""><br class="">We'd like to submit this code and proceed.<br class="">The goal is to let setting rounding mode in intrinsics. The operations that we talk about are FP arithmetic - like FADD, FMUL, FSUB, FDIV, FMA - 512 bit vector only.<br class="">And FP conversions. Nothing more, so there is no correlation with masks.<br class=""><br class="">I see 2 options right now.<br class=""><br class="">1. define an additional X86 node type for each intrinsic<br class="">2. Wrap the existing node with ROUNDMODE<br class=""><br class="">In the patch we are giving solution number 2 and say that it is safe. If ROUNDMODE and FADD will be separated, the compilation will fail with "cannot select".<br class="">Do you still have any concerns?<br class=""></blockquote><br class="">FWIW I totally share Adam's concerns, but I'll admit I don't have a<br class="">better alternative to creating all the specific nodes, and that<br class="">doesn't seem perfect either.<br class=""><br class="">How about - and this is totally handwavy - adding a single new node,<br class="">having all of the operation, rounding mode, and mask as operands?  I<br class="">don't know if there's precedent, but since you say we're late in the<br class="">SelectionDAG, your only problem would then be to match these,<br class="">correct?  That might involve some tweaks in tablegen to be able to<br class="">specify an FP op as an operand, but that doesn't sound too hard.  In<br class="">the SelectionDAG proper, the operation "operand" would simply be a<br class="">ConstantSDNode, holding the ISD opcode.<br class=""><br class="">Say something like:<br class="">  (AVX512OpWithRounding fadd, op1, op2, <rounding mode, ...>)<br class=""><br class="">I'm guessing you won't be able to reuse the existing "fadd"/... in<br class="">tablegen, but adding a few new defs, with a 1-to-1 mapping with the<br class="">ISD opcode, should do the trick.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Naive question: why not directly matching the intrinsics themselves without using an intermediate ISD?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I assumed it was the way to go when there is a 1-1 mapping between an intrinsic and a specific instruction?</span><br class=""></div></blockquote><br class=""></div><div>I have the same question.  This seems way over-engineered to me.</div><div><br class=""></div><div>—Owen</div></body></html>