<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Feb 18, 2014, at 9:37 AM, Quentin Colombet <<a href="mailto:qcolombet@apple.com">qcolombet@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Tom,<br><br>On Feb 18, 2014, at 9:21 AM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:<br><br><blockquote type="cite">Hi Quentin,<br><br>Sorry I missed this on the first time around: <br><br><blockquote type="cite">--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp<br>+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp<br>@@ -1728,6 +1730,35 @@<br>TypePromotionHelper::promoteOperandForOther(Instruction *SExt,<br> return SExtOpnd;<br>}<br><br>+/// IsPromotionProfitable - Check whether or not promoting an<br>instruction<br>+/// to a wider type was profitable.<br>+/// \p MatchedSize gives the number of instructions that have been<br>matched<br>+/// in the addressing mode after the promotion was applied.<br>+/// \p SizeWithPromotion gives the number of created instructions for<br>+/// the promotion plus the number of instructions that have been<br>+/// matched in the addressing mode before the promotion.<br>+/// \p PromotedOperand is the value that has been promoted.<br>+/// \return True if the promotion is profitable, false otherwise.<br>+bool<br>+AddressingModeMatcher::IsPromotionProfitable(unsigned MatchedSize,<br>+                                             unsigned SizeWithPromotion,<br>+                                             Value *PromotedOperand) const {<br>+  // We folded less instructions than what we created to promote the operand.<br>+  // This is not profitable.<br>+  if (MatchedSize < SizeWithPromotion)<br>+    return false;<br>+  if (MatchedSize > SizeWithPromotion)<br>+    return true;<br>+  // The promotion is neutral but it may help folding the signextension in<br>+  // loads for instance.<br>+  // Check that we did not create an illegal instruction.<br>+  Instruction *PromotedInst = dyn_cast<Instruction>(PromotedOperand);<br>+  if (!PromotedInst)<br>+    return false;<br>+  return TLI.isOperationLegalOrCustom(PromotedInst->getOpcode(),<br>+                                      EVT::getEVT(PromotedInst->getType()));<br></blockquote><br>This won't work, because the IR Instructions and SelectionDAG Opcodes<br>have different enumeration values.<br></blockquote>Right, good catch!<br><br><blockquote type="cite"> The original test case must have<br>passed, because it is using a default TargetLowering implementation<br>rather than the one from R600.<br><br>I've attached an updated version of the original test case which compiles<br>the program using llc and triggers the bug again.<br><br>I couldn't find other transforms that use the isOperation* callbacks, so<br>I think you may have to add a function to convert from IR Instruction to<br>SelectionDAG Opcodes or implement this some other way.<br></blockquote>I think a specific hook in TargetLowering may be the best approach here.<br>Let me see what I can come up with.<br>If you have ideas on the naming, let me know :).<br></blockquote><div>In fact, we may be able to use this:</div><div>int TargetLoweringBase::InstructionOpcodeToISD(<a class="el" href="http://llvm.org/doxygen/classunsigned.html" style="color: rgb(61, 33, 133); text-decoration: none; font-weight: bold; cursor: pointer;">unsigned</a> <em>Opcode</em>)const</div><br><blockquote type="cite"><br>Cheers,<br>Quentin<br><blockquote type="cite"><br>Thanks,<br>Tom<br><update-cgp-test.case.diff><br></blockquote><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></blockquote></div><br></body></html>