As in 33257, I was playing around with division+remainder code, and found another case gcc didn't optimize. I was using signed and unsigned variants, and tried a couple different constants. The test case was optimized properly with the constant 3 (signed or unsigned math), and with the constant 128 if unsigned math was used. Using 128 with signed math, the test didn't get optimized away.
Created attachment 14144 [details] C test case, description and assembly in comments
After a little more experimentation, it appears that the signed-math cases that do get optimized are those with positive divisors that are not powers of two. If the divisors are powers of two (so that the operations can be done with shifts and masks?), or are negative, then the test and abort call don't get optimized away. (There's an edge case with INT_MIN/-1 possibly yielding undefined results without -fwrapv. I didn't test -1, but did test a handful of other negative numbers, where the results should be fully defined.)
Fixed in GCC 10+ by r10-137.