Basically you are sampling a texture from a non uniform control flow (inside an if statement)
cf Texture sampler and non uniform control flow
TLDR:
Add #define DISABLE_UNIFORMITY_ANALYSIS
to your shader code, or find a way to sample the texture from a uniform control flow.