<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jun 25, 2009, at 4:38 PM, David Goodwin wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Using the Thumb-2 target we see that ORN ( a | ^b) and BIC (a & ^b) have similar patterns, as we would expect:<div><br></div><div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 12px;">defm t2BIC : T2I_bin_irs<"bic", BinOpFrag<(and node:$LHS, (not node:$RHS))>>;</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 12px;">defm t2ORN : T2I_bin_irs<"orn", BinOpFrag<(or node:$LHS, (not node:$RHS))>>;</span></font></div><div><br></div><div>Compiling the following three works as expected:</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 12px;"> %tmp1 = xor i32 4294967295, %b ; %tmp2 = or i32 %a, %tmp1 --> </span></font><span class="Apple-tab-span" style="white-space:pre"><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><font class="Apple-style-span" face="'Courier New'"> </font></span></font></span><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px;"><font class="Apple-style-span" face="'Courier New'">orn r0, r0, r1</font></span></font></div><div><div><font class="Apple-style-span" face="'Courier New'"> %tmp1 = xor i32 4294967295, %b ; %tmp2 = or i32 %tmp1, %a --> orn r0, r0, r1</font></div></div><div><div><font class="Apple-style-span" face="'Courier New'"> %tmp = xor i32 %b, 4294967295 ; %tmp1 = and i32 %a, %tmp --> bic r0, r0, r1</font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div>But this doesn't:</div><div><br></div><div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 12px;"> %tmp = xor i32 %b, 4294967295 ; %tmp1 = and i32 %tmp, %a --> eor r1, r1, #4294967295 ; a<span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 12px;">nd r0, r1, r0</span></font></span></span></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div>On the surface it seems that the selector is not commuting the AND operands. I've attached the complete test files. I can take a look but I need a pointer to get started.</div></div></div></div></div></div></blockquote><div><br></div>No, isel is trying to commute the AND. See ARMGenDAGISel.inc (auto-generated by tablegen):</div><div><br></div><div><div> // Pattern: (and:i32 GPR:i32:$lhs, (xor:i32 t2_so_reg:i32:$rhs, (imm:i32)<<P:Predicate_immAllOnes>>)) </div><div> // Emits: (t2BICrs:i32 GPR:i32:$lhs, t2_so_reg:i32:$rhs) </div><div> // Pattern complexity = 19 cost = 1 size = 0 </div><div> {</div><div> ..</div><div> }</div><div><br></div><div><div><br></div><div> // Pattern: (and:i32 (xor:i32 t2_so_reg:i32:$rhs, (imm:i32)<<P:Predicate_immAllOnes>>), GPR:i32:$lhs) </div><div> // Emits: (t2BICrs:i32 GPR:i32:$lhs, t2_so_reg:i32:$rhs) </div><div> // Pattern complexity = 19 cost = 1 size = 0</div><div> {</div><div> ...</div><div> }</div><div><br></div><div>The second one is the commuted version. Looks like the issue is in SelectThumb2ShifterOperandReg.</div><div><br></div><div>Evan</div><div><br></div><div><br></div></div><blockquote type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div><br></div><div>David</div><div><br></div><div></div></div></div></div></div></div><span><RM_20_BIC.ll></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div></div></div></div></div></div></div><span><RM_112_ORN.ll></span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div><div><div><div> </div></div></div></div></div></div>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></body></html>