This patch fixes pr32292 correctly. In order to see the patch really works on the test case, r299124 and r299125 need to be reverted to reveal the mis-compile. Tested with r299124 and r299125 reverted locally.
The getPristine usage seems still inaccurate, but we can fix that later.