[PATCH] D157690: [GlobalISel] Rewrite some simple rules using MIR Patterns

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 03:27:29 PDT 2023


Pierre-vh marked an inline comment as done.
Pierre-vh added inline comments.


================
Comment at: llvm/include/llvm/Target/GlobalISel/Combine.td:674-675
+  (defs root:$dst),
+  (match  (G_FNEG $tmp, $x),
+          (G_FABS $dst, $tmp)),
+  (apply (G_FABS $dst, $x))>;
----------------
foad wrote:
> Is the order of instructions significant here? Would it still match if I wrote `(match (G_FABS $dst, $tmp), (G_FNEG $tmp, $x))` instead?
The order doesn't matter at all, it emits patterns by walking the "tree" from the root instruction, following the operands to their defs recursively 
For instance below `add_sub_reg_frags` orders the patterns differently


================
Comment at: llvm/test/CodeGen/AArch64/GlobalISel/combine-select.mir:12
     ; CHECK-LABEL: name: test_combine_select_same_res
-    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+    ; CHECK: liveins: $x0, $x1
+    ; CHECK-NEXT: {{  $}}
----------------
foad wrote:
> What has caused this difference?
Below in `test_combine_select_undef_res0_res1` we have a copy `$x0` instead of `$x1`, not sure why


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157690



More information about the llvm-commits mailing list