Skip to content

Commit 1e74ae3

Browse files
committed
LoongArch: Cleanup __builtin_constant_p() checking for cpu_has_*
In the current configuration, cpu_has_lsx and cpu_has_lasx cannot be constants. So cleanup the __builtin_constant_p() checking to reduce the complexity. Reviewed-by: WANG Xuerui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 4eece7e commit 1e74ae3

File tree

1 file changed

+4
-11
lines changed
  • arch/loongarch/include/asm

1 file changed

+4
-11
lines changed

arch/loongarch/include/asm/fpu.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,8 @@ static inline void restore_lsx(struct task_struct *t)
218218

219219
static inline void init_lsx_upper(void)
220220
{
221-
/*
222-
* Check cpu_has_lsx only if it's a constant. This will allow the
223-
* compiler to optimise out code for CPUs without LSX without adding
224-
* an extra redundant check for CPUs with LSX.
225-
*/
226-
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx)
227-
return;
228-
229-
_init_lsx_upper();
221+
if (cpu_has_lsx)
222+
_init_lsx_upper();
230223
}
231224

232225
static inline void restore_lsx_upper(struct task_struct *t)
@@ -294,15 +287,15 @@ static inline void restore_lasx_upper(struct task_struct *t) {}
294287

295288
static inline int thread_lsx_context_live(void)
296289
{
297-
if (__builtin_constant_p(cpu_has_lsx) && !cpu_has_lsx)
290+
if (!cpu_has_lsx)
298291
return 0;
299292

300293
return test_thread_flag(TIF_LSX_CTX_LIVE);
301294
}
302295

303296
static inline int thread_lasx_context_live(void)
304297
{
305-
if (__builtin_constant_p(cpu_has_lasx) && !cpu_has_lasx)
298+
if (!cpu_has_lasx)
306299
return 0;
307300

308301
return test_thread_flag(TIF_LASX_CTX_LIVE);

0 commit comments

Comments
 (0)