[MSWin] Tentative measure for a bug of VS2022 [Misc #18362]

Disable the use of `__assume()`, when combinations of `isnan()`,
`isinf()` and `__assume()` will be wrongly optimized due to the
bug of VS2022.
This commit is contained in:
Nobuyoshi Nakada 2022-02-12 23:29:19 +09:00
Родитель 32af1a3b5e
Коммит ed8776f960
2 изменённых файлов: 51 добавлений и 0 удалений

Просмотреть файл

@ -702,7 +702,9 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
#define ALWAYS_INLINE(x) __forceinline x #define ALWAYS_INLINE(x) __forceinline x
#define WARN_UNUSED_RESULT(x) x #define WARN_UNUSED_RESULT(x) x
#define MAYBE_UNUSED(x) x #define MAYBE_UNUSED(x) x
!if !defined(VS2022_FP_BUG)
#define HAVE___ASSUME 1 #define HAVE___ASSUME 1
!endif
#define FUNC_STDCALL(x) __stdcall x #define FUNC_STDCALL(x) __stdcall x
#define FUNC_CDECL(x) __cdecl x #define FUNC_CDECL(x) __cdecl x
#define FUNC_FASTCALL(x) __fastcall x #define FUNC_FASTCALL(x) __fastcall x

Просмотреть файл

@ -123,6 +123,55 @@ int main(void) {FILE *volatile f = stdin; return 0;}
-headers-: nul -headers-: nul
-headers-: vs2022-fp-bug
# Check the bug reported at:
# https://developercommunity.visualstudio.com/t/With-__assume-isnan-after-isinf/1515649
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
vs2022-fp-bug:
@echo checking for $(@:-= )
@echo <<$@.c > NUL
/* compile with -O2 */
#include <math.h>
#include <float.h>
#define value_finite(d) 'f'
#define value_infinity() 'i'
#define value_nan() 'n'
#ifdef NO_ASSUME
# define ASSUME_TRUE() (void)0
#else
# define ASSUME_TRUE() __assume(1)
#endif
static int
check_value(double value)
{
if (isinf(value)) {
return value_infinity();
}
else if (isnan(value)) {
return value_nan();
}
ASSUME_TRUE();
return value_finite(value);
}
int
main(void)
{
int c = check_value(nan(""));
printf("NaN=>%c\n", c);
return c != value_nan();
}
<<
@( \
($(CC) -O2 -DNO_ASSUME $@.c && .\$@ && $(CC) -O2 $@.c) && \
(.\$@ || echo>>$(MAKEFILE) VS2022_FP_BUG=1) \
) & $(WIN32DIR:/=\)\rm.bat $@.*
-version-: nul verconf.mk -version-: nul verconf.mk
verconf.mk: nul verconf.mk: nul