[llvm] [SLSR] Fix slsr gep stride delta miscompile (PR #204278)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 19:54:06 PDT 2026


================
@@ -639,6 +639,68 @@ static void unifyBitWidth(APInt &A, APInt &B) {
     B = B.sext(A.getBitWidth());
 }
 
+// `xor X, signmask` merely flips the sign bit, but ScalarEvolution models it as
+// a non-nsw `add X, signmask`. So a stride `xor X, signmask` and a stride X
+// look like they differ by the constant signmask in the narrow type, even
+// though sext(xor X, signmask) - sext(X) is not that constant (it is +signmask
+// or -signmask depending on the sign of X).
+static bool isXorSignMask(const Value *V) {
----------------
fengfeng09 wrote:

Updated.

https://github.com/llvm/llvm-project/pull/204278


More information about the llvm-commits mailing list