diff --git a/tests/assembly/asm/aarch64-modifiers.rs b/tests/assembly/asm/aarch64-modifiers.rs
index a3956d21a06..58f7c114d3a 100644
--- a/tests/assembly/asm/aarch64-modifiers.rs
+++ b/tests/assembly/asm/aarch64-modifiers.rs
@@ -1,6 +1,6 @@
 //@ add-core-stubs
 //@ assembly-output: emit-asm
-//@ compile-flags: -O -C panic=abort
+//@ compile-flags: -Copt-level=3 -C panic=abort
 //@ compile-flags: --target aarch64-unknown-linux-gnu
 //@ compile-flags: -Zmerge-functions=disabled
 //@ needs-llvm-components: aarch64
@@ -15,7 +15,7 @@ use minicore::*;
 
 macro_rules! check {
     ($func:ident $reg:ident $code:literal) => {
-        // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
+        // -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0
         #[no_mangle]
         pub unsafe extern "C" fn $func() -> i32 {
             let y;
diff --git a/tests/assembly/asm/aarch64-outline-atomics.rs b/tests/assembly/asm/aarch64-outline-atomics.rs
index 46586f0f31c..5990fb84942 100644
--- a/tests/assembly/asm/aarch64-outline-atomics.rs
+++ b/tests/assembly/asm/aarch64-outline-atomics.rs
@@ -1,5 +1,5 @@
 //@ assembly-output: emit-asm
-//@ compile-flags: -O
+//@ compile-flags: -Copt-level=3
 //@ compile-flags: --target aarch64-unknown-linux-gnu
 //@ needs-llvm-components: aarch64
 //@ only-aarch64
diff --git a/tests/assembly/asm/arm-modifiers.rs b/tests/assembly/asm/arm-modifiers.rs
index 562b6bed74c..32a36840492 100644
--- a/tests/assembly/asm/arm-modifiers.rs
+++ b/tests/assembly/asm/arm-modifiers.rs
@@ -1,6 +1,6 @@
 //@ add-core-stubs
 //@ assembly-output: emit-asm
-//@ compile-flags: -O -C panic=abort
+//@ compile-flags: -Copt-level=3 -C panic=abort
 //@ compile-flags: --target armv7-unknown-linux-gnueabihf
 //@ compile-flags: -C target-feature=+neon
 //@ compile-flags: -Zmerge-functions=disabled
@@ -21,7 +21,7 @@ impl Copy for f32x4 {}
 
 macro_rules! check {
     ($func:ident $modifier:literal $reg:ident $ty:ident $mov:literal) => {
-        // -O and extern "C" guarantee that the selected register is always r0/s0/d0/q0
+        // -Copt-level=3 and extern "C" guarantee that the selected register is always r0/s0/d0/q0
         #[no_mangle]
         pub unsafe extern "C" fn $func() -> $ty {
             let y;
diff --git a/tests/assembly/asm/x86-modifiers.rs b/tests/assembly/asm/x86-modifiers.rs
index 53e4b92f84a..5f68e5c7317 100644
--- a/tests/assembly/asm/x86-modifiers.rs
+++ b/tests/assembly/asm/x86-modifiers.rs
@@ -1,7 +1,7 @@
 //@ add-core-stubs
 //@ revisions: x86_64 i686
 //@ assembly-output: emit-asm
-//@ compile-flags: -O -C panic=abort
+//@ compile-flags: -Copt-level=3 -C panic=abort
 //@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
 //@[x86_64] needs-llvm-components: x86
 //@[i686] compile-flags: --target i686-unknown-linux-gnu
@@ -20,7 +20,7 @@ use minicore::*;
 
 macro_rules! check {
     ($func:ident $modifier:literal $reg:ident $mov:literal) => {
-        // -O and extern "C" guarantee that the selected register is always ax/xmm0
+        // -Copt-level=3 and extern "C" guarantee that the selected register is always ax/xmm0
         #[no_mangle]
         pub unsafe extern "C" fn $func() -> i32 {
             let y;
diff --git a/tests/assembly/libs/issue-115339-zip-arrays.rs b/tests/assembly/libs/issue-115339-zip-arrays.rs
index 956459b2c77..098382502e8 100644
--- a/tests/assembly/libs/issue-115339-zip-arrays.rs
+++ b/tests/assembly/libs/issue-115339-zip-arrays.rs
@@ -1,6 +1,6 @@
 //@ assembly-output: emit-asm
 // # zen3 previously exhibited odd vectorization
-//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -O
+//@ compile-flags: --crate-type=lib -Ctarget-cpu=znver3 -Copt-level=3
 //@ only-x86_64
 //@ ignore-sgx
 
diff --git a/tests/assembly/manual-eq-efficient.rs b/tests/assembly/manual-eq-efficient.rs
index 817ce94f476..8dafed354be 100644
--- a/tests/assembly/manual-eq-efficient.rs
+++ b/tests/assembly/manual-eq-efficient.rs
@@ -1,6 +1,6 @@
 // Regression test for #106269
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
 //@ only-x86_64
 //@ ignore-sgx
 
diff --git a/tests/assembly/panic-no-unwind-no-uwtable.rs b/tests/assembly/panic-no-unwind-no-uwtable.rs
index 24626280155..b51b173e961 100644
--- a/tests/assembly/panic-no-unwind-no-uwtable.rs
+++ b/tests/assembly/panic-no-unwind-no-uwtable.rs
@@ -1,6 +1,6 @@
 //@ assembly-output: emit-asm
 //@ only-x86_64-unknown-linux-gnu
-//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -O
+//@ compile-flags: -C panic=unwind -C force-unwind-tables=n -Copt-level=3
 
 #![crate_type = "lib"]
 
diff --git a/tests/assembly/powerpc64-struct-abi.rs b/tests/assembly/powerpc64-struct-abi.rs
index db08a514819..0332eb94d8a 100644
--- a/tests/assembly/powerpc64-struct-abi.rs
+++ b/tests/assembly/powerpc64-struct-abi.rs
@@ -1,6 +1,6 @@
 //@ revisions: elfv1-be elfv2-be elfv2-le aix
 //@ assembly-output: emit-asm
-//@ compile-flags: -O
+//@ compile-flags: -Copt-level=3
 //@[elfv1-be] compile-flags: --target powerpc64-unknown-linux-gnu
 //@[elfv1-be] needs-llvm-components: powerpc
 //@[elfv2-be] compile-flags: --target powerpc64-unknown-linux-musl
diff --git a/tests/assembly/s390x-backchain-toggle.rs b/tests/assembly/s390x-backchain-toggle.rs
index 8b6d0cf2123..7ef0292d911 100644
--- a/tests/assembly/s390x-backchain-toggle.rs
+++ b/tests/assembly/s390x-backchain-toggle.rs
@@ -1,6 +1,6 @@
 //@ revisions: enable-backchain disable-backchain
 //@ assembly-output: emit-asm
-//@ compile-flags: -O --crate-type=lib --target=s390x-unknown-linux-gnu
+//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu
 //@ needs-llvm-components: systemz
 //@[enable-backchain] compile-flags: -Ctarget-feature=+backchain
 //@[disable-backchain] compile-flags: -Ctarget-feature=-backchain
diff --git a/tests/assembly/s390x-vector-abi.rs b/tests/assembly/s390x-vector-abi.rs
index c1935582561..7d86559c002 100644
--- a/tests/assembly/s390x-vector-abi.rs
+++ b/tests/assembly/s390x-vector-abi.rs
@@ -1,7 +1,7 @@
 //@ revisions: z10 z10_vector z13 z13_no_vector
 // ignore-tidy-linelength
 //@ assembly-output: emit-asm
-//@ compile-flags: -O -Z merge-functions=disabled
+//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled
 //@[z10] compile-flags: --target s390x-unknown-linux-gnu --cfg no_vector
 //@[z10] needs-llvm-components: systemz
 //@[z10_vector] compile-flags: --target s390x-unknown-linux-gnu -C target-feature=+vector
diff --git a/tests/assembly/simd-bitmask.rs b/tests/assembly/simd-bitmask.rs
index 9a355cc162f..4a829c4dd98 100644
--- a/tests/assembly/simd-bitmask.rs
+++ b/tests/assembly/simd-bitmask.rs
@@ -10,7 +10,7 @@
 //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
 //@ [aarch64] needs-llvm-components: aarch64
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-gather.rs b/tests/assembly/simd-intrinsic-gather.rs
index 29b0df64065..3152de35f29 100644
--- a/tests/assembly/simd-intrinsic-gather.rs
+++ b/tests/assembly/simd-intrinsic-gather.rs
@@ -3,7 +3,7 @@
 //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
 //@ [x86-avx512] needs-llvm-components: x86
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-mask-load.rs b/tests/assembly/simd-intrinsic-mask-load.rs
index 89b35ed7734..efe3e3752fa 100644
--- a/tests/assembly/simd-intrinsic-mask-load.rs
+++ b/tests/assembly/simd-intrinsic-mask-load.rs
@@ -6,7 +6,7 @@
 //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
 //@ [x86-avx512] needs-llvm-components: x86
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-mask-reduce.rs b/tests/assembly/simd-intrinsic-mask-reduce.rs
index 8ac55990c73..4d4adda6c24 100644
--- a/tests/assembly/simd-intrinsic-mask-reduce.rs
+++ b/tests/assembly/simd-intrinsic-mask-reduce.rs
@@ -7,7 +7,7 @@
 //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
 //@ [aarch64] needs-llvm-components: aarch64
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-mask-store.rs b/tests/assembly/simd-intrinsic-mask-store.rs
index 1686fd5dd88..f5d924f24a7 100644
--- a/tests/assembly/simd-intrinsic-mask-store.rs
+++ b/tests/assembly/simd-intrinsic-mask-store.rs
@@ -6,7 +6,7 @@
 //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
 //@ [x86-avx512] needs-llvm-components: x86
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-scatter.rs b/tests/assembly/simd-intrinsic-scatter.rs
index 3f4d7569c59..5f52ababd19 100644
--- a/tests/assembly/simd-intrinsic-scatter.rs
+++ b/tests/assembly/simd-intrinsic-scatter.rs
@@ -3,7 +3,7 @@
 //@ [x86-avx512] compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bw,+avx512dq
 //@ [x86-avx512] needs-llvm-components: x86
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd-intrinsic-select.rs b/tests/assembly/simd-intrinsic-select.rs
index 803abf2eeb3..74784a77213 100644
--- a/tests/assembly/simd-intrinsic-select.rs
+++ b/tests/assembly/simd-intrinsic-select.rs
@@ -8,7 +8,7 @@
 //@ [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu
 //@ [aarch64] needs-llvm-components: aarch64
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C panic=abort
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C panic=abort
 
 #![feature(no_core, lang_items, repr_simd, intrinsics)]
 #![no_core]
diff --git a/tests/assembly/simd/reduce-fadd-unordered.rs b/tests/assembly/simd/reduce-fadd-unordered.rs
index ade60ba184c..e872826f6ef 100644
--- a/tests/assembly/simd/reduce-fadd-unordered.rs
+++ b/tests/assembly/simd/reduce-fadd-unordered.rs
@@ -1,6 +1,7 @@
 //@ revisions: x86_64 aarch64
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O
+//@ compile-flags: --crate-type=lib -Copt-level=3
+
 //@[aarch64] only-aarch64
 //@[x86_64] only-x86_64
 //@[x86_64] compile-flags: -Ctarget-feature=+sse3
diff --git a/tests/assembly/slice-is_ascii.rs b/tests/assembly/slice-is_ascii.rs
index 3a050347d89..e53cd5160cf 100644
--- a/tests/assembly/slice-is_ascii.rs
+++ b/tests/assembly/slice-is_ascii.rs
@@ -2,7 +2,7 @@
 //@ [WIN] only-windows
 //@ [LIN] only-linux
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
 //@ only-x86_64
 //@ ignore-sgx
 
diff --git a/tests/assembly/x86-return-float.rs b/tests/assembly/x86-return-float.rs
index acd1af8d38a..423263c9673 100644
--- a/tests/assembly/x86-return-float.rs
+++ b/tests/assembly/x86-return-float.rs
@@ -6,7 +6,7 @@
 // Use the same target CPU as `i686` so that LLVM orders the instructions in the same order.
 //@ compile-flags: -Ctarget-feature=+sse2 -Ctarget-cpu=pentium4
 // Force frame pointers to make ASM more consistent between targets
-//@ compile-flags: -O -C force-frame-pointers
+//@ compile-flags: -Copt-level=3 -C force-frame-pointers
 //@ filecheck-flags: --implicit-check-not fld --implicit-check-not fst
 //@ revisions: normal win
 //@[normal] ignore-windows
diff --git a/tests/assembly/x86_64-array-pair-load-store-merge.rs b/tests/assembly/x86_64-array-pair-load-store-merge.rs
index 849f34e72e5..56a1a9e8206 100644
--- a/tests/assembly/x86_64-array-pair-load-store-merge.rs
+++ b/tests/assembly/x86_64-array-pair-load-store-merge.rs
@@ -1,5 +1,5 @@
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel
 //@ only-x86_64
 //@ ignore-sgx
 //@ ignore-apple (manipulates rsp too)
diff --git a/tests/assembly/x86_64-bigint-helpers.rs b/tests/assembly/x86_64-bigint-helpers.rs
index 3ad253a2bd0..58785932bc2 100644
--- a/tests/assembly/x86_64-bigint-helpers.rs
+++ b/tests/assembly/x86_64-bigint-helpers.rs
@@ -1,6 +1,6 @@
 //@ only-x86_64
 //@ assembly-output: emit-asm
-//@ compile-flags: --crate-type=lib -O -C target-cpu=x86-64-v4
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C target-cpu=x86-64-v4
 //@ compile-flags: -C llvm-args=-x86-asm-syntax=intel
 //@ revisions: llvm-pre-20 llvm-20
 //@ [llvm-20] min-llvm-version: 20
diff --git a/tests/assembly/x86_64-floating-point-clamp.rs b/tests/assembly/x86_64-floating-point-clamp.rs
index c05afadff64..6b0c29c5f21 100644
--- a/tests/assembly/x86_64-floating-point-clamp.rs
+++ b/tests/assembly/x86_64-floating-point-clamp.rs
@@ -3,7 +3,7 @@
 
 //@ assembly-output: emit-asm
 // Set the base cpu explicitly, in case the default has been changed.
-//@ compile-flags: --crate-type=lib -O -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64
+//@ compile-flags: --crate-type=lib -Copt-level=3 -C llvm-args=-x86-asm-syntax=intel -C target-cpu=x86-64
 //@ only-x86_64
 //@ ignore-sgx
 
diff --git a/tests/assembly/x86_64-function-return.rs b/tests/assembly/x86_64-function-return.rs
index 7cfdf5bce0c..7fd57200a9e 100644
--- a/tests/assembly/x86_64-function-return.rs
+++ b/tests/assembly/x86_64-function-return.rs
@@ -3,7 +3,7 @@
 
 //@ revisions: unset keep thunk-extern keep-thunk-extern thunk-extern-keep
 //@ assembly-output: emit-asm
-//@ compile-flags: -O
+//@ compile-flags: -Copt-level=3
 //@ [keep] compile-flags: -Zfunction-return=keep
 //@ [thunk-extern] compile-flags: -Zfunction-return=thunk-extern
 //@ [keep-thunk-extern] compile-flags: -Zfunction-return=keep -Zfunction-return=thunk-extern
diff --git a/tests/assembly/x86_64-no-jump-tables.rs b/tests/assembly/x86_64-no-jump-tables.rs
index 9b781226232..bb10042d8f6 100644
--- a/tests/assembly/x86_64-no-jump-tables.rs
+++ b/tests/assembly/x86_64-no-jump-tables.rs
@@ -3,7 +3,7 @@
 
 //@ revisions: unset set
 //@ assembly-output: emit-asm
-//@ compile-flags: -O
+//@ compile-flags: -Copt-level=3
 //@ [set] compile-flags: -Zno-jump-tables
 //@ only-x86_64
 //@ ignore-sgx