Compare register value using logical AND (&) and ==
When you write if REG &amp; 0x10 you're checking whether bit 4 of the register REG is set.
If the value of REG is 0x30, then bit 4 is set, and you should do the thing you want to do when bit 4 is set.
If the value of the REG is 0x20 then bit 4 isn't set, so you shouldn't do the thing you want to do when bit 4 is set.
And that's exactly the behavior you get if you write if REG &amp; 0x10 {...}.

What I don't understand is why the code uses GPIO_PORTE_RIS_R &amp; 0x10 to compare register value instead of GPIO_PORTE_RIS_R == 0x10.

If you used == then if bit 4 was set, but some other bit was also set, then you wouldn't do whatever it is you want to do when bit 4 is set.
But since you want to do that thing when bit 4 is set regardless of what other bits are set, then this is wrong.