[llvm] [SCEVExpander] Support hoisting udiv X, Y where Y is non-zero (PR #96102)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 12:07:08 PDT 2024
================
@@ -11,26 +11,29 @@ define void @test(i16 %x, i64 %y, ptr %ptr) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[CONV19:%.*]] = sext i16 [[X:%.*]] to i64
; CHECK-NEXT: [[ADD:%.*]] = add i64 [[CONV19]], 492802768830814067
+; CHECK-NEXT: [[TMP0:%.*]] = udiv i64 [[Y:%.*]], [[ADD]]
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw nsw i64 [[TMP0]], 4
+; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP0]], 1
+; CHECK-NEXT: [[TMP3:%.*]] = udiv i64 [[TMP1]], [[TMP2]]
+; CHECK-NEXT: [[TMP4:%.*]] = add nuw nsw i64 [[TMP3]], 1
+; CHECK-NEXT: [[TMP5:%.*]] = add nuw nsw i64 [[TMP0]], 1
; CHECK-NEXT: br label [[LOOP_PREHEADER:%.*]]
; CHECK: loop.preheader:
-; CHECK-NEXT: [[DIV:%.*]] = udiv i64 [[Y:%.*]], [[ADD]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv i64 [[Y]], [[ADD]]
----------------
nikic wrote:
Why are we generating two divisions now, one in entry and one in the preheader?
https://github.com/llvm/llvm-project/pull/96102
More information about the llvm-commits
mailing list