Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Altivec instructions on PowerPC unless requested #337

Closed
wants to merge 1 commit into from

Conversation

smcv
Copy link

@smcv smcv commented Jan 10, 2018

Baseline PowerPC CPUs are not guaranteed to have Altivec instructions
available, even if they are 64-bit.

Unlike SSE and similar extensions on x86, there does not seem to be
a way to enable conditional, targeted use of Altivec based on runtime
detection (which is what ioquake3 wants to do) without also giving the
compiler permission to use Altivec in code generation; so to not crash
on the affected CPUs, we'll have to turn it off altogether.

At one point Altivec was an important optimization, because the
most commonly available PowerPC CPUs (in Apple G4/G5 hardware)
had the Altivec instructions, and they were a significant benefit
there. However, Apple haven't sold PowerPC devices for over 10 years,
some more recently-manufactured PowerPC CPUs like the (64-bit) Freescale
e5500 omit Altivec, and CPUs in general are a lot faster now than they
were when the idTech3 engine was first released, hopefully making the
optimization unnecessary.

This commit uses -mno-altivec to force Altivec instructions not to be
emitted, unless Altivec is requested via "make USE_ALTIVEC=1". The Apple
fork of gcc doesn't document the corresponding -fno-altivec option, so
we'll have to assume that omitting -faltivec is enough (but non-Altivec
Macs haven't been sold for a long time anyway).

Bug: #181
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561
Tested-by: @casey-ac

Baseline PowerPC CPUs are not guaranteed to have Altivec instructions
available, even if they are 64-bit.

Unlike SSE and similar extensions on x86, there does not seem to be
a way to enable conditional, targeted use of Altivec based on runtime
detection (which is what ioquake3 wants to do) without also giving the
compiler permission to use Altivec in code generation; so to not crash
on the affected CPUs, we'll have to turn it off altogether.

At one point Altivec was an important optimization, because the
most commonly available PowerPC CPUs (in Apple G4/G5 hardware)
had the Altivec instructions, and they were a significant benefit
there. However, Apple haven't sold PowerPC devices for over 10 years,
some more recently-manufactured PowerPC CPUs like the (64-bit) Freescale
e5500 omit Altivec, and CPUs in general are a lot faster now than they
were when the idTech3 engine was first released, hopefully making the
optimization unnecessary.

This commit uses -mno-altivec to force Altivec instructions not to be
emitted, unless Altivec is requested via "make USE_ALTIVEC=1". The Apple
fork of gcc doesn't document the corresponding -fno-altivec option, so
we'll have to assume that omitting -faltivec is enough (but non-Altivec
Macs haven't been sold for a long time anyway).

Bug: ioquake#181
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701561
Tested-by: casey-ac <https://github.com/casey-ac>
@smcv
Copy link
Author

smcv commented May 11, 2018

#368 is an alternative to this PR.

@zturtleman
Copy link
Member

Fixed using a different method by #368.

@zturtleman zturtleman closed this May 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants