www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - LDC internal error message (with no line number) but source compiles

reply Cecil Ward <cecil cecilward.com> writes:
The short D module below compiles successfully with GDC but LDC 
fails:

gdc 13.1 :    -O3 -frelease -march=native
compiles ok

ldc 1.32.1:  -O3 -release -mcpu=native
== ldc ::
sext source and destination must both be a vector or neither
   %26 = sext i32 9 to <4 x i64>
LLVM ERROR: Broken function found, compilation aborted!
Stack dump without symbol names (ensure you have llvm-symbolizer 
in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to 
point to it):
/opt/compiler-explorer/ldc1.32.1/ldc2-1.32.1-linux-x86_64/bin/ldc2(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamEi+0x23)[0x56402ddef413]
Compiler returned: 139

== D source code follows: ==

import std.stdint;
import core.simd;


public
uint64_t
hashi( const uint64_t * p, size_t len ) pure nothrow  nogc
	{
	uint64_t s = 0;
	for ( size_t i = 0; i < len; i++ )
		{
		s ^= ( p[i] * 509 ) ^ ( p[i] >>> 9 );
		}
	return s;
	}


alias uint64_256_t = ulong4;
alias uint64x4_t = uint64_256_t;
alias uint64_32_t = uint64_256_t;

public
uint64_t
hashv( const uint64_256_t * p, size_t len ) pure nothrow  nogc
	{
	uint64_256_t s1 = [0, 0, 0, 0];
	for ( size_t i = 0; i < len; i++ )
		{
		const x = p[i];
		s1 ^= (x * 509) ^ (x >>> 9);
		}
	const nsz = (*p).sizeof * 8 / 64;
	const uint64_t[nsz] v = cast(uint64_t[nsz]) s1;
	uint64_t s = 0;
	for ( size_t i = 0; i < len; i++ )
		{
		s ^= v[i];
		}
	return s;
	}
Jun 13 2023
parent kinke <noone nowhere.com> writes:
This is https://github.com/ldc-developers/ldc/issues/3606, here 
about `p[i] >>> 9`. The frontend for some reason doesn't promote 
scalars to vectors for shifts (but for arithmetic ops); an 
explicit `x >>> uint64_256_t(9)` compiles.
Jun 14 2023