[llvm] [SCEVExpander] Support hoisting udiv X, Y where Y is non-zero (PR #96102)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 08:48:06 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]]
----------------
preames wrote:
We're not. The one in the preheader is there in the input code. We're failing to CSE here, but that's it.
https://github.com/llvm/llvm-project/pull/96102
More information about the llvm-commits
mailing list