On Wed, Jan 10, 2024 at 07:05:39PM +0000, Andre Vieira (lists) wrote:
> This patch is still work in progress, but posting to show failure with
> bitint-7 test where handle_stmt called from lower_mergeable_stmt ICE's
> because the idx (3) is out of range for the __BitInt(135) with a limb_prec
> of 64.

I can reproduce it, will debug it momentarily.

> I hacked gcc locally to work around this issue and still have one
> outstanding failure, so will look to resolve that failure before posting a
> new version.

I see 2 issues in your patch:
1) as written earlier, the bitint lowering pass doesn't yet support big
   endian, so I think at least temporarily we shouldn't pretend it works
   until it is fixed;
   https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626847.html
   mentions the big-endian issues
2) for n in [65, 128] I believe the aarch64 ABI says that _BitInt should be
   treated the same as __int128; so for those cases we want limb_mode =
   abi_limb_mode = TImode; those cases are just lowered to TImode
   arithmetics, there is no attempt to treat those as arrays of smaller
   limbs.
   It is just the [129, 65535] cases where we want limb_mode DImode (for
   efficiency and implementability) and abi_limb_mode TImode (for the ABI
   reasons, alignment, sizing, ...), i.e. the cases where the ABI says
   it is treated as an array of the 128-bit limbs

--- gcc/config/aarch64/aarch64.cc.jj    2024-01-11 09:37:28.000000000 +0100
+++ gcc/config/aarch64/aarch64.cc       2024-01-11 09:41:03.440202903 +0100
@@ -28279,12 +28279,20 @@ aarch64_excess_precision (enum excess_pr
 bool
 aarch64_bitint_type_info (int n, struct bitint_info *info)
 {
+  /* For now, the middle-end bitint lowering doesn't handle big endian.  */
+  if (TARGET_BIG_END)
+    return false;
+
   if (n <= 8)
     info->limb_mode = QImode;
   else if (n <= 16)
     info->limb_mode = HImode;
   else if (n <= 32)
     info->limb_mode = SImode;
+  else if (n <= 64)
+    info->limb_mode = DImode;
+  else if (n <= 128)
+    info->limb_mode = TImode;
   else
     info->limb_mode = DImode;
 


        Jakub

Reply via email to