[Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2"

2023-02-09 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

--- Comment #20 from Erich Eckner  ---
Yeah, now it pulled some stuff :-)

0 0 000a 746e6543 736c7561 48727561 
0 1 000a 746e6543 736c7561 48727561 
1 0 06fa 00010800 008863a9 afc9fbff 
1 1 06fa 00010800 008863a9 afc9fbff 
2 0 02b3b001   2c04307d 
2 1 02b3b001   2c04307d 
3 0     
3 1     
4 0     
4 1     
5 0 0040 0040 0003 0000 
5 1 0040 0040 0003 0000 
6 0 0002    
6 1 0002    
7 0     
7 1     
8 0     
8 1     
9 0     
9 1     
10 0 06280202   0503 
10 1 06280202   0503 
-2147483648 0 8008    
-2147483648 1 8008    
-2147483647 0   0001 20100800 
-2147483647 1   0001 20100800 
-2147483646 0 20202020 20202020 20202020 20202020 
-2147483646 1 20202020 20202020 20202020 20202020 
-2147483645 0 20202020 20202020 49562020 614e2041 
-2147483645 1 20202020 20202020 49562020 614e2041 
-2147483644 0 55206f6e 30303433 30303840 007a484d 
-2147483644 1 55206f6e 30303433 30303840 007a484d 
-2147483643 0  08800880 40100140 40100140 
-2147483643 1  08800880 40100140 40100140 
-2147483642 0   04008140  
-2147483642 1   04008140  
-2147483641 0     
-2147483641 1    

Thank you for your time!

[Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2"

2023-02-09 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

--- Comment #17 from Erich Eckner  ---
With that, I get a segfault in cpuid():

(gdb) run
Starting program: /tmp/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x5191 in cpuid ()
(gdb) bt
#0  0x5191 in cpuid ()
#1  0x51ef in main ()
(gdb) 

... same on x86_64 - maybe, there's a typo, somewhere?

[Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2"

2021-05-26 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

Erich Eckner  changed:

   What|Removed |Added

 Status|RESOLVED|ASSIGNED
 Resolution|WONTFIX |---

--- Comment #7 from Erich Eckner  ---
Yes, we could do

#include 
unsigned int regs[4];
__get_cpuid(0, regs, regs+1, regs+2, regs+3);
if (regs[3] & bit_SSE2) {
  ...
}

The "cumbersome" in my first comment referred to doing all that by hand, which
was the alternative, we saw so far.

Ok, I'll switch to that code and stop bothering you :-)

Thanks for looking into this!

[Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2"

2021-05-26 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

--- Comment #4 from Erich Eckner  ---
Created attachment 50871
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50871=edit
cpuid probing

Does the attached program yield, what you need? (Sry, I'm quite unfamiliar with
asm in gcc)

It gives:

0001 746e6543 736c7561 48727561 
06d0 0800 4181 a7c9bbff 

and

000a 746e6543 736c7561 48727561 
06fa 00010800 008863a9 afc9fbff 

on the two machines, respectively.

[Bug target/100758] __builtin_cpu_supports does not (always) detect "sse2"

2021-05-26 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

--- Comment #2 from Erich Eckner  ---
We use this in archlinux32 to detect, if we can install packages, that have
sse2 opcodes:

If one sets "Architecture = auto" in /etc/pacman.conf, uname only gives "i686"
in both cases (this is how archlinux does/did the probing), and then, we probe
for sse2 to check, if we really are "i686" or "pentium4" (our nomenclature for
"i686" + sse2). This works well on amd and intel cpus, but fails on via cpus.

Details about expected features: https://archlinux32.org/architecture/

We can add some cumbersome code which probes for sse2, but I'd really prefer
some compiler builtin instead :-)

[Bug c/100758] New: __builtin_cpu_supports does not (always) detect "sse2"

2021-05-25 Thread gcc at eckner dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100758

Bug ID: 100758
   Summary: __builtin_cpu_supports does not (always) detect "sse2"
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at eckner dot net
  Target Milestone: ---
  Host: i686
Target: i686

Created attachment 50868
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50868=edit
test.c: probe for sse2

I use the attached snippet to detect, whether the cpu supports sse2. This works
most of the time, but fails to detect sse2 on two machines, which actually
support sse2 (according to /proc/cpuinfo).

The affected machines run archlinux32. /proc/cpuinfo shows:

processor   : 0
vendor_id   : CentaurHauls
cpu family  : 6
model   : 15
model name  : VIA Nano U3400@800MHz
stepping: 10
cpu MHz : 798.016
cache size  : 2048 KB
physical id : 0
siblings: 1
core id : 0
cpu cores   : 1
apicid  : 0
initial apicid  : 0
fdiv_bug: no
f00f_bug: no
coma_bug: no
fpu : yes
fpu_exception   : yes
cpuid level : 10
wp  : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat clflush acpi mmx fxsr sse sse2 ss tm syscall nx lm constant_tsc
arch_perfmon rep_good cpuid pni monitor vmx est tm2 ssse3 cx16 xtpr sse4_1
popcnt rng rng_en ace ace_en ace2 phe phe_en pmm pmm_en lahf_lm tpr_shadow vnmi
vpid ida
vmx flags   : vnmi tsc_offset vtpr
bugs: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds
swapgs itlb_multihit
bogomips: 1596.53
clflush size: 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:

and
processor   : 0
vendor_id   : CentaurHauls
cpu family  : 6
model   : 13
model name  : VIA C7-D Processor 1800MHz
stepping: 0
cpu MHz : 1596.326
cache size  : 128 KB
physical id : 0
siblings: 1
core id : 0
cpu cores   : 1
apicid  : 0
initial apicid  : 0
fdiv_bug: no
f00f_bug: no
coma_bug: no
fpu : yes
fpu_exception   : yes
cpuid level : 1
wp  : yes
flags   : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge cmov pat
clflush acpi mmx fxsr sse sse2 tm nx cpuid pni est tm2 xtpr rng rng_en ace
ace_en ace2 ace2_en phe phe_en pmm pmm_en
bugs: cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf mds
swapgs itlb_multihit
bogomips: 3193.67
clflush size: 64
cache_alignment : 64
address sizes   : 36 bits physical, 32 bits virtual
power management:

respectively. On these machines, the output is "sse2: 0" instead of some value
unequal 0.

Regards,
Erich

P.S.: I hope, I reported this in the correct category. Please let me know, if I
did not.