Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: backend cannot select in neon code #1883

@georgthegreat

Description

@georgthegreat

Description

Hi.

I am trying to update xnnpack to 2023-04-18 / 71f70de09ca17f125d3c24ccceeb12045a674d0c in order to update tensorflow-lite to 2.12.0.

Unfortunately clang for android segfaults when compiling src/bf16-gemm/gen/bf16-gemm-1x4c8-minmax-neonbf16-bfdot.c for android-armv7a.

I am able to reproduce this:

${NDK}/llvm-toolchain/bin/clang --target=armv7a-linux-androideabi21 -isystem ${NDK}/sources/cxx-stl/llvm-libc++abi/include -fsigned-char -march=armv7-a -mfloat-abi=softfp -c -o ${SRC}/contrib/restricted/google/xnnpack/src/bf16-gemm/gen/bf16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.c.o -I${SRC} -I${SRC}/contrib/libs/fxdiv -I${SRC}/contrib/libs/pthreadpool/include -I${SRC}/contrib/restricted/google/xnnpack/include -I${SRC}/contrib/libs/fxdiv/include -I${SRC}/contrib/restricted/cpuinfo/include -I${SRC}/contrib/restricted/google/xnnpack/src -I${SRC}/contrib/libs/cxxsupp/libcxx/include -I${SRC}/contrib/libs/fp16/include -I${SRC}/contrib/libs/zlib/include -I${SRC}/contrib/libs/double-conversion -I${SRC}/contrib/libs/libc_compat/include/ifaddrs -fdebug-prefix-map=${SRC}=/-B -Xclang -fdebug-compilation-dir -Xclang /tmp -pipe -O3 -g -fexceptions -fno-common -fcolor-diagnostics -faligned-allocation -fdebug-default-version=4 -ffunction-sections -fdata-sections -w  -DXNN_ENABLE_ARM_BF16=1 -DXNN_ENABLE_ARM_DOTPROD=1 -DXNN_ENABLE_ARM_FP16_SCALAR=1 -DXNN_ENABLE_ARM_FP16_VECTOR=1 -DXNN_ENABLE_ASSEMBLY=1 -DXNN_ENABLE_DWCONV_MULTIPASS=0 -DXNN_ENABLE_GEMM_M_SPECIALIZATION=1 -DXNN_ENABLE_JIT=0 -DXNN_ENABLE_MEMOPT=1 -DXNN_ENABLE_RISCV_VECTOR=1 -DXNN_ENABLE_SPARSE=1 -DXNN_LOG_LEVEL=0 -Werror-implicit-function-declaration -nostdinc++ -fPIE -fPIE -march=armv8.2-a+bf16 -mfpu=neon-fp-armv8 ${SRC}/contrib/restricted/google/xnnpack/src/bf16-gemm/gen/bf16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.c

I have tested NDK's r25b and r25c, but the segfault still persists and there is no way to fix this.

fatal error: error in backend: Cannot select: 0x90a21a8: v4bf16 = extract_subvector 0x909e178, Constant:i32<0>, /home/thegeorg/arcadia/contrib/restricted/google/xnnpack/src/bf16-gemm/gen/bf
16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.c:173:33
  0x909e178: v8bf16,i32,ch = ARMISD::VLD1_UPD<(load (s128) from %ir.362, align 2)> 0x8f06068, 0x8cafc48, 0x8cb05a0, Constant:i32<1>, /home/thegeorg/arcadia/contrib/restricted/google/xnnpack
/src/bf16-gemm/gen/bf16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.c:163:32
    0x8cafc48: i32,ch = CopyFromReg 0x8f06068, Register:i32 %84, /home/thegeorg/arcadia/contrib/restricted/google/xnnpack/src/bf16-gemm/gen/bf16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.
c:163:32
      0x8cb0260: i32 = Register %84
    0x8cb05a0: i32,ch = CopyFromReg 0x8f06068, Register:i32 %70, /home/thegeorg/arcadia/contrib/restricted/google/xnnpack/src/bf16-gemm/gen/bf16-gemm-6x8c2-minmax-neonbf16-bfdot-lane-ld128.
c:158:89
      0x8cafe50: i32 = Register %70
    0x909e380: i32 = Constant<1>
  0x90b3a08: i32 = Constant<0>
In function: xnn_bf16_gemm_minmax_ukernel_6x8c2__neonbf16_bfdot_lane_ld128
PLEASE submit a bug report to https://github.com/android-ndk/ndk/issues and include the crash backtrace, preprocessed source, and associated run script.

I have tested ndk r25b and r25c, but the issue persists.
Classic clang 14.0.x does not seems to be affected by the problem.

Upstream bug

No response

Commit to cherry-pick

No response

Affected versions

r25

Canary version

No response

Host OS

Linux

Host OS version

Ubuntu 20.04

Affected ABIs

armeabi-v7a

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions