From 53a9819283e26dedae13bb33d928eb733ee569d8 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Thu, 8 Mar 2018 12:24:33 +0200 Subject: [PATCH] Disabled GCC loop vectorization for R_LoadKVX() function This prevents crash (unaligned memory access by SSE instruction) on loading voxels in Release (-O3) builds https://forum.zdoom.org/viewtopic.php?t=59656 --- src/r_data/voxels.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/r_data/voxels.cpp b/src/r_data/voxels.cpp index c982f0382..e9a9b89fc 100644 --- a/src/r_data/voxels.cpp +++ b/src/r_data/voxels.cpp @@ -180,6 +180,11 @@ static void RemapVoxelSlabs(kvxslab_t *dest, int size, const uint8_t *remap) // //========================================================================== +#if defined __GNUC__ && !defined __clang__ +#pragma GCC push_options +#pragma GCC optimize ("-fno-tree-loop-vectorize") +#endif // __GNUC__ && !__clang__ + FVoxel *R_LoadKVX(int lumpnum) { const kvxslab_t *slabs[MAXVOXMIPS]; @@ -320,6 +325,10 @@ FVoxel *R_LoadKVX(int lumpnum) return voxel; } +#if defined __GNUC__ && !defined __clang__ +#pragma GCC pop_options +#endif // __GNUC__ && !__clang__ + //========================================================================== // //