<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 10:30 AM, Tom Stellard <<a href="mailto:tom@stellard.net">tom@stellard.net</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="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;">On Tue, Feb 18, 2014 at 09:47:21AM -0800, Quentin Colombet wrote:<br><blockquote type="cite"><br>On Feb 18, 2014, at 9:37 AM, Quentin Colombet <<a href="mailto:qcolombet@apple.com">qcolombet@apple.com</a>> wrote:<br><br><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:<span class="Apple-converted-space"> </span><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>In fact, we may be able to use this:<br>int TargetLoweringBase::InstructionOpcodeToISD(unsigned Opcode)const<br></blockquote><br>Oh, I didn't see that.  That should work.<br></div></blockquote><div>Almost there.</div><div>I am seeing a link error when creating the bugpoint executable.</div><div><br></div><div><div style="margin: 0px; font-size: 11px; font-family: Menlo;"><div style="margin: 0px;">llvm[2]: Linking Release executable bugpoint (without symbols)</div></div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">Undefined symbols for architecture x86_64:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">  "llvm::TargetLoweringBase::InstructionOpcodeToISD(unsigned int) const", referenced from:</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">      (anonymous namespace)::AddressingModeMatcher::MatchOperationAddr(llvm::User*, unsigned int, unsigned int, bool*) in libLLVMScalarOpts.a(CodeGenPrepare.o)</div><div style="margin: 0px; font-size: 11px; font-family: Menlo;">ld: symbol(s) not found for architecture x86_64</div><div><br></div></div>The thing that I do not understand is why the linker is not find this function, whereas it does not complain about TargetLoweringBase::isLegalAddressingMode.</div><div>I may have missed something obvious, but I do not see it.</div><div><br></div><div>Any idea?</div><div><br></div><div>Thanks,</div><div>-Quentin<br><blockquote type="cite"><div style="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;"><br>-Tom<br><blockquote type="cite"><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><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></blockquote></blockquote></div></blockquote></div><br></body></html>