[llvm] [X86] Add APX imulzu support. (PR #116806)
Daniel Zabawa via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 08:20:00 PST 2024
================
@@ -0,0 +1,238 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mattr=+zu | FileCheck %s --check-prefix=ZU
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=NOZU
+
+; Test generation of 16b imulzu when -mattr=+zu is specified.
+; The mulzu_* tests check for basic generation, which will fold away a zero-extend of the
+; result if present.
+; The following tests are modifications of selected test/CodeGen/X86/imul.ll tests with
+; 16b multiplies, to check that common strength reductions in ISel are still performed
+; when -mattr=+zu is in effect.
+;
+; FIXME: several cases from imul.ll covering DAG combines, in particular those using LEA,
+; are not ported as X86's IsDesirableToPromoteOp has no way to accurately identify when
+; promotion will permit a better sequence than an unpromoted imulzu.
+; These cases should be added when they are implemented.
+
+define i32 @mulzu_16_32(i16 %A) {
+; ZU-LABEL: mulzu_16_32:
+; ZU: # %bb.0:
+; ZU-NEXT: imulzuw $1234, %di, %ax # imm = 0x4D2
+; ZU-NEXT: retq
+;
+; NOZU-LABEL: mulzu_16_32:
+; NOZU: # %bb.0:
+; NOZU-NEXT: imull $1234, %edi, %eax # imm = 0x4D2
+; NOZU-NEXT: movzwl %ax, %eax
+; NOZU-NEXT: retq
+ %mul = mul i16 %A, 1234
+ %r = zext i16 %mul to i32
+ ret i32 %r
----------------
daniel-zabawa wrote:
The cases at, e.g. line 87 do not have zero extends. I can add a sign-extended case though I consider it to be the same as the non-zero-extended case.
https://github.com/llvm/llvm-project/pull/116806
More information about the llvm-commits
mailing list