[PATCH] D127115: [DAGCombine] Make sure combined nodes are added back to the worklist in topological order.

Nabeel Omer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 07:34:47 PDT 2023


n-omer added a comment.

In D127115#4399236 <https://reviews.llvm.org/D127115#4399236>, @RKSimon wrote:

>   define void @_ZN12_GLOBAL__N_114AssemblyWriterC2ERN4llvm21formatted_raw_ostreamERNS1_11SlotTrackerEPKNS1_6ModuleEPNS1_24AssemblyAnnotationWriterEbb() {
>   entry:
>     %__end1.sroa.5.0.copyload = load ptr, ptr poison, align 8
>     %__end1.sroa.6.0.copyload = load ptr, ptr null, align 8
>     %cmp.i.i.i8.i.i = icmp ne ptr null, %__end1.sroa.6.0.copyload
>     %cmp.i.i.i.i9.i.i = icmp ne ptr null, %__end1.sroa.5.0.copyload
>     %.not.i = select i1 %cmp.i.i.i8.i.i, i1 true, i1 %cmp.i.i.i.i9.i.i
>     %.not.i.fr = freeze i1 %.not.i
>     br i1 %.not.i.fr, label %for.cond.us, label %if.end.split
>   
>   for.cond.us:                                      ; preds = %entry
>     unreachable
>   
>   if.end.split:                                     ; preds = %entry
>     ret void
>   }

We've also identified this issue in an internal codebase built with this patch, the problem is that `// X != Y   -->  (X^Y)` in `TargetLowering::SimplifySetCC` and `Transform (brcond (xor x, y)) -> (brcond (setcc, x, y, ne))` in `DAGCombiner::rebuildSetCC` keep undoing each other without an end:

  Combining: t1517: ch = brcond t0, t1520, BasicBlock:ch<if.end.split 0x1ae28ac5070>
  Creating new node: t1522: i1 = setcc t1521, Constant:i1<-1>, setne:ch
  Creating new node: t1523: ch = brcond t0, t1522, BasicBlock:ch<if.end.split 0x1ae28ac5070>
   ... into: t1523: ch = brcond t0, t1522, BasicBlock:ch<if.end.split 0x1ae28ac5070>
  
  Combining: t1521: i1 = freeze t9
  
  Combining: t1523: ch = brcond t0, t1522, BasicBlock:ch<if.end.split 0x1ae28ac5070>
  
  Combining: t1522: i1 = setcc t1521, Constant:i1<-1>, setne:ch
  Creating new node: t1524: i1 = setcc t9, Constant:i1<-1>, setne:ch
  Creating new node: t1525: i1 = freeze t1524
   ... into: t1525: i1 = freeze t1524
  
  Combining: t1525: i1 = freeze t1524
  
  Combining: t1524: i1 = setcc t9, Constant:i1<-1>, setne:ch
  Creating new node: t1526: i1 = xor t9, Constant:i1<-1>
   ... into: t1526: i1 = xor t9, Constant:i1<-1>
  
  Combining: t1526: i1 = xor t9, Constant:i1<-1>
  
  Combining: t1525: i1 = freeze t1526
  Creating new node: t1527: i1 = freeze t9
   ... into: t1526: i1 = xor t1527, Constant:i1<-1>
  
  Combining: t1526: i1 = xor t1527, Constant:i1<-1>
  
  Combining: t1527: i1 = freeze t9
  
  Combining: t1523: ch = brcond t0, t1526, BasicBlock:ch<if.end.split 0x1ae28ac5070> --------> Back to where we started.
  Creating new node: t1528: i1 = setcc t1527, Constant:i1<-1>, setne:ch
  Creating new node: t1529: ch = brcond t0, t1528, BasicBlock:ch<if.end.split 0x1ae28ac5070>
   ... into: t1529: ch = brcond t0, t1528, BasicBlock:ch<if.end.split 0x1ae28ac5070>


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127115/new/

https://reviews.llvm.org/D127115



More information about the llvm-commits mailing list