Skip to content

Commit 6146a88

Browse files
Ami-zhangtstellar
authored andcommitted
[LoongArch] Fix '-mno-lsx' option not disabling LASX feature (#143821)
When '-march' with LASX feature and '-mno-lsx' options are used together, '-mno-lsx' fails to disable LASX, leaving 'HasFeatureLASX=true' and causing incorrect '__loongarch_sx/asx=1' macro definition. Fixes loongson-community/discussions#95 (cherry picked from commit 2ecbfc0)
1 parent 9ba132b commit 6146a88

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Driver/ToolChains/Arch/LoongArch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
253253
Features.push_back("+lsx");
254254
} else /*-mno-lsx*/ {
255255
Features.push_back("-lsx");
256+
Features.push_back("-lasx");
256257
}
257258
}
258259

clang/test/Preprocessor/init-loongarch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,10 @@
946946
// RUN: | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
947947
// RUN: %clang --target=loongarch64 -mno-lasx -mno-lsx -x c -E -dM %s -o - \
948948
// RUN: | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
949+
// RUN: %clang --target=loongarch64 -march=la464 -mno-lsx -x c -E -dM %s -o - \
950+
// RUN: | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
951+
// RUN: %clang --target=loongarch64 -mno-lsx -march=la464 -x c -E -dM %s -o - \
952+
// RUN: | FileCheck --match-full-lines --check-prefix=MNO-LSX %s
949953
// MNO-LSX-NOT: #define __loongarch_asx
950954
// MNO-LSX-NOT: #define __loongarch_simd_width
951955
// MNO-LSX-NOT: #define __loongarch_sx

0 commit comments

Comments
 (0)