SimplifyWithOpReplaced has AllowRefinement argument, but when it further calls SimplifyXXX,
the flag isn't properly passed.
This causes the simplifying calls to fold possibly-poison values into non-poison constant
even if AllowRefinement is set to false.
This causes miscompilation https://llvm.org/pr49495.
simplifySelectWithICmpCond calls SimplifyWithOpReplaced with AllowRefinement set to false.
However, the information is lost, causing computePointerICmp to do folding based on inbounds flag.
computePointerICmp transforms (gep inbounds x, -1) >u x into -1 >s 0 which is correct only if
inbounds is set (https://alive2.llvm.org/ce/z/mGwYxH vs. https://alive2.llvm.org/ce/z/e-2KQh ).
To fix this, this patch updates simplifySelectWithICmpCond to call SimplifyWithOpReplaced with Q.getWithoutRefinement().
SimplifyQuery::getWithoutRefinement() is a new method that simply returns a new object with relevant flags set to false.
If this flag is set, simplifications cannot fold the value into a more defined one.
This wasn't enough to fix the pointer folding, and I updated computePointerICmp and its relevant calls to respect relevant flags.
clang-format not found in user's PATH; not linting file.