# Is this compiler bug in Zig or LLVM?

**URL:** <https://ziggit.dev/t/is-this-compiler-bug-in-zig-or-llvm/16022>\
**Category:** Help\
**Tags:** compiler, build-system\
**Created:** [June 8, 2026, 2:40pm UTC](https://ziggit.dev/t/is-this-compiler-bug-in-zig-or-llvm/16022 "2026-06-08T14:40:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![auburnsummer](https://ziggit.dev/user_avatar/ziggit.dev/auburnsummer/32/8973_2.png) [@auburnsummer](https://ziggit.dev/u/auburnsummer)\
**Post date:** [June 8, 2026, 2:40pm UTC](https://ziggit.dev/t/is-this-compiler-bug-in-zig-or-llvm/16022/1 "2026-06-08T14:40:59Z")

</div>

Hi, I’ve been doing some attempts at Playstation 1 homebrew development with Zig. The PS1’s CPU uses the MIPS-I instruction set, so I target it using `-target mipsel-freestanding -mcpu mips1`.

I think I found a bug:

With divisions, the compiled output when safety checks are enabled includes the `teq` (Trap if equal) instruction to check for divide by zero. The MIPS-I instruction set does not have this yet, it was [introduced in MIPS-II](https://en.wikipedia.org/wiki/MIPS_architecture#MIPS_II).

So the bug is that the compiled output includes `teq` even when the `mips1` CPU is targeted. Here’s a godbolt link, the teq is on line 25: [Compiler Explorer](https://godbolt.org/z/b1GvbcGYE)

I’m unsure who or how to report this. Is it an LLVM bug or a Zig bug? (…or do I have my compiler flags wrong?)

(For now, I’m able to continue by always compiling with `OReleaseFast` no matter what. It does mean I don’t get proper asserts though ☹ )

---

<div class="post-metadata">

**Author:** ![alexrp](https://ziggit.dev/user_avatar/ziggit.dev/alexrp/32/2793_2.png) [@alexrp](https://ziggit.dev/u/alexrp)\
**Post date:** [June 8, 2026, 2:46pm UTC](https://ziggit.dev/t/is-this-compiler-bug-in-zig-or-llvm/16022/2 "2026-06-08T14:46:53Z")

</div>

This is an LLVM bug. Its support for MIPS III and older is very experimental/incomplete.

---

<div class="post-metadata">

**Author:** ![auburnsummer](https://ziggit.dev/user_avatar/ziggit.dev/auburnsummer/32/8973_2.png) [@auburnsummer](https://ziggit.dev/u/auburnsummer)\
**Post date:** [June 9, 2026, 3:27pm UTC](https://ziggit.dev/t/is-this-compiler-bug-in-zig-or-llvm/16022/3 "2026-06-09T15:27:44Z")

</div>

Thanks. Just in case anyone else stumbles across this with the same issue, I did some searching and found this issue in the LLVM bug tracker: [mips1 target generates invalid instruction · Issue #80554 · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/issues/80554)

and it looks like there is a PR for a fix as well! [[Mips] Handle division by zero trap on MIPS1 by neoto · Pull Request #201133 · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/pull/201133)
