Look into -Wtautological-compare warnings in unregisterised builds
When building the wasm backend with unregisterised mode (e.g. https://gitlab.haskell.org/ghc/ghc/-/jobs/1258935), I noticed the build log contains a lot of warnings that look like:
/tmp/ghc99977_0/ghc_3.hc:1490:16: error:
warning: self-comparison always evaluates to true [-Wtautological-compare]
|
1490 | if ((W_)(_s1sp == _s1sp)) goto _c1Bt; else goto _c1Bu;
| ^
if ((W_)(_s1sp == _s1sp)) goto _c1Bt; else goto _c1Bu;
And it's not just the wasm backend, the same warnings can be seen when building GHC for x86_64-linux and configuring with ./configure --enable-unregisterised CONF_CC_OPTS_STAGE2=-Wtautological-compare.
This looks like something that gcc/clang would optimize away, but I'm still filing a ticket for it. The root cause is the RawCmmGroups produced at the end of Cmm pipeline indeed contain this kind of suboptimal code. There should be some Cmm pass that eliminates it.