Skip to content

Commit d142e05

Browse files
committed
simplify gates in CPUFeatures
1 parent f00ad59 commit d142e05

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

HashLib/src/Utils/HlpCpuFeatures.pas

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ class function TCpuFeatures.CPUHasAVX2(): Boolean;
8484
LXcr0: UInt64;
8585
{$ENDIF}
8686
begin
87-
{$IFNDEF HASHLIB_X86_SIMD}
88-
Result := False;
89-
{$ELSE}
90-
{$IFDEF HASHLIB_I386_ASM}
91-
Result := False;
92-
{$ELSE}
87+
{$IFDEF HASHLIB_X86_SIMD}
9388
CpuIdQuery(1, 0, @LCpuId);
9489

9590
// OSXSAVE: ECX bit 27 (required for OS AVX state saving)
@@ -106,7 +101,8 @@ class function TCpuFeatures.CPUHasAVX2(): Boolean;
106101

107102
// AVX2: EBX bit 5
108103
Result := (LCpuId.RegEBX and (1 shl 5)) <> 0;
109-
{$ENDIF}
104+
{$ELSE}
105+
Result := False;
110106
{$ENDIF}
111107
end;
112108

@@ -116,16 +112,12 @@ class function TCpuFeatures.CPUHasSHANI(): Boolean;
116112
LCpuId: TCpuIdResult;
117113
{$ENDIF}
118114
begin
119-
{$IFNDEF HASHLIB_X86_SIMD}
120-
Result := False;
121-
{$ELSE}
122-
{$IFDEF HASHLIB_I386_ASM}
123-
Result := False;
124-
{$ELSE}
115+
{$IFDEF HASHLIB_X86_SIMD}
125116
CpuIdQuery(7, 0, @LCpuId);
126117
// SHA-NI: EBX bit 29
127118
Result := (LCpuId.RegEBX and (1 shl 29)) <> 0;
128-
{$ENDIF}
119+
{$ELSE}
120+
Result := False;
129121
{$ENDIF}
130122
end;
131123

0 commit comments

Comments
 (0)