[llvm] [SimplifyCFG] handle monotonic wrapped case for D150943 (PR #65882)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 10 22:47:26 PDT 2023
================
@@ -2039,3 +2039,32 @@ return:
%x = phi i8 [ 3, %sw.default ], [ 124, %sw.bb3 ], [ -99, %sw.bb2 ], [ -66, %sw.bb1 ], [ -33, %entry ]
ret i8 %x
}
+
+define i8 @linearmap_dec_wrapped_mon(i3 %0) { ; Assume 1
+; CHECK-LABEL: @linearmap_dec_wrapped_mon(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SWITCH_TABLEIDX:%.*]] = sub i3 [[TMP0:%.*]], -2
+; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i3 [[SWITCH_TABLEIDX]], -4
+; CHECK-NEXT: [[SWITCH_IDX_MULT:%.*]] = mul i3 [[SWITCH_TABLEIDX]], 2
+; CHECK-NEXT: [[SWITCH_OFFSET:%.*]] = add i3 [[SWITCH_IDX_MULT]], -4
+; CHECK-NEXT: [[COND:%.*]] = select i1 [[TMP1]], i3 [[SWITCH_OFFSET]], i3 2
+; CHECK-NEXT: [[CONV:%.*]] = sext i3 [[COND]] to i8
+; CHECK-NEXT: ret i8 [[CONV]]
+;
+entry:
+ switch i3 %0, label %cond.end [
+ i3 -1, label %cond.false
+ i3 -2, label %cond.false
+ i3 1, label %cond.false ; -> %cond.false
----------------
mikaelholmen wrote:
Same here
https://github.com/llvm/llvm-project/pull/65882
More information about the llvm-commits
mailing list