[llvm] [InstCombine] Canonicalize gep scaling factor (PR #180216)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 2 07:47:48 PST 2026
================
@@ -40,8 +40,9 @@ define ptr @pos_pow2_8(ptr %foo, i64 %x) {
define ptr @pos_not_i8(ptr %foo, i64 %x) {
; CHECK-LABEL: define ptr @pos_not_i8(
; CHECK-SAME: ptr [[FOO:%.*]], i64 [[X:%.*]]) {
-; CHECK-NEXT: [[IDX1:%.*]] = and i64 [[X]], 3
-; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds nuw i32, ptr [[FOO]], i64 [[IDX1]]
+; CHECK-NEXT: [[IDX:%.*]] = srem i64 [[X]], 4
+; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i64 [[IDX]], 2
+; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds nuw i8, ptr [[FOO]], i64 [[TMP1]]
----------------
nikic wrote:
Regression (`srem -> (and/urem) for inbounds+nuw GEP` fold).
https://github.com/llvm/llvm-project/pull/180216
More information about the llvm-commits
mailing list