[llvm] 3ddf368 - [X86] Fix warning in cpu detection due to unsigned comparison

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 29 18:02:25 PST 2023


Author: Aiden Grossman
Date: 2023-12-29T17:58:53-08:00
New Revision: 3ddf3685248a8c3ef07bf8290196c33521edb894

URL: https://github.com/llvm/llvm-project/commit/3ddf3685248a8c3ef07bf8290196c33521edb894
DIFF: https://github.com/llvm/llvm-project/commit/3ddf3685248a8c3ef07bf8290196c33521edb894.diff

LOG: [X86] Fix warning in cpu detection due to unsigned comparison

a15532d7647a8a4b7fd2889bd97f6f72f273c4bf landed a patch that added
support for detecting more AMD znver2 CPUs and cleaned up some of the
surrounding code, including the znver3 detection. Since one model group
is 00h-0fh, I adjusted the check to include checking if the value is
greater than zero. Since the value is unsigned, this is always true and
gcc warns on it. This patch removes the comparison with zero to get rid
of the compiler warning.

Added: 
    

Modified: 
    compiler-rt/lib/builtins/cpu_model/x86.c
    llvm/lib/TargetParser/Host.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/builtins/cpu_model/x86.c b/compiler-rt/lib/builtins/cpu_model/x86.c
index c6a917715e12c9..9d9a5d3f1542cd 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -676,7 +676,7 @@ static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
   case 25:
     CPU = "znver3";
     *Type = AMDFAM19H;
-    if ((Model >= 0x00 && Model <= 0x0f) || (Model >= 0x20 && Model <= 0x2f) ||
+    if ((Model <= 0x0f) || (Model >= 0x20 && Model <= 0x2f) ||
         (Model >= 0x30 && Model <= 0x3f) || (Model >= 0x40 && Model <= 0x4f) ||
         (Model >= 0x50 && Model <= 0x5f)) {
       // Family 19h Models 00h-0Fh (Genesis, Chagall) Zen 3

diff  --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 11c5000acc077d..2e08c7b12d9d5d 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -1160,7 +1160,7 @@ getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
   case 25:
     CPU = "znver3";
     *Type = X86::AMDFAM19H;
-    if ((Model >= 0x00 && Model <= 0x0f) || (Model >= 0x20 && Model <= 0x2f) ||
+    if (Model <= 0x0f || (Model >= 0x20 && Model <= 0x2f) ||
         (Model >= 0x30 && Model <= 0x3f) || (Model >= 0x40 && Model <= 0x4f) ||
         (Model >= 0x50 && Model <= 0x5f)) {
       // Family 19h Models 00h-0Fh (Genesis, Chagall) Zen 3


        


More information about the llvm-commits mailing list