[SystemZ] Fix codegen for _[u]128 intrinsics
commit149884a1469d83720ea524763fdf461a74af8ecb
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 19 Sep 2024 11:18:43 +0000 (19 13:18 +0200)
committerTobias Hieta <tobias@hieta.se>
Fri, 11 Oct 2024 06:03:12 +0000 (11 08:03 +0200)
treeaec3cfd63500188dbb465188655119cf268e8c7b
parentf3f49528c419e4d7be9df8eeafa57dea2701ac47
[SystemZ] Fix codegen for _[u]128 intrinsics

PR #74625 introduced a regression in the code generated for the
following set of intrinsic:
  vec_add_u128, vec_addc_u128, vec_adde_u128, vec_addec_u128
  vec_sub_u128, vec_subc_u128, vec_sube_u128, vec_subec_u128
  vec_sum_u128, vec_msum_u128
  vec_gfmsum_128, vec_gfmsum_accum_128

This is because the new code incorrectly assumed that a cast
from "unsigned __int128" to "vector unsigned char" would simply
be a bitcast re-interpretation; instead, this cast actually
truncates the __int128 to char and splats the result.

Fixed by adding an intermediate cast via a single-element
128-bit integer vector.

Fixes: https://github.com/llvm/llvm-project/issues/109113
(cherry picked from commit baf9b7da81025c1e3b0704d7ecf667e06f95642b)
clang/lib/Headers/vecintrin.h
clang/test/CodeGen/SystemZ/builtins-systemz-i128.c [new file with mode: 0644]