[llvm] [GlobalISel] Combine G_MERGE_VALUES of undef (PR #113381)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 05:32:29 PDT 2024


Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>,
Thorsten =?utf-8?q?Schütt?= <schuett at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/113381 at github.com>


================
@@ -420,7 +420,8 @@ def unary_undef_to_zero: GICombineRule<
 // replaced with undef.
 def propagate_undef_any_op: GICombineRule<
   (defs root:$root),
-  (match (wip_match_opcode G_ADD, G_FPTOSI, G_FPTOUI, G_SUB, G_XOR, G_TRUNC, G_BITCAST, G_ANYEXT):$root,
+  (match (wip_match_opcode G_ADD, G_FPTOSI, G_FPTOUI, G_SUB, G_XOR, G_TRUNC, G_BITCAST,
+                           G_ANYEXT, G_MERGE_VALUES):$root,
----------------
lenary wrote:

Right now with this optimisation, the function returns 128-bit zero, but if we try to validate the equivalent optimisation just with LLVM IR (i.e., replacing the whole function with `ret i128 0`, alive2 really complains, and shows an input where the return values don't actually match according to the IR: https://alive2.llvm.org/ce/z/8gdDkw

I believe @regehr also has a tool to do LLVM IR to AArch64 Assembly translation validation, which I believe would also agree that this optimisation, as implemented, is wrong.

https://github.com/llvm/llvm-project/pull/113381


More information about the llvm-commits mailing list