XC32 optimizes vaiable used for register reading
Compiler optimizations typically assume that nothing but the program itself can alter the contents of memory. With that assumption, repeated reads from the same register on a microcontroller are often optimized out, because the compiler doesn't see anything in the code that can possibly give a different result with repeated execution. Why execute the same instructions over and over if the result will always be the same?

Volatile is the workaround. It tells the compiler that something else in the universe might alter that particular address in memory, and that its assumptions about future values aren't necessarily true. "Don't optimize me, bro".

In short, I think things are behaving exactly as intended.