; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[IDX:%.*]], 5
; CHECK-NEXT: br i1 [[CMP]], label [[CHECK_MAX:%.*]], label [[TRAP]]
; CHECK: check.max:
-; CHECK-NEXT: [[IDX_SHL:%.*]] = shl nuw i32 [[IDX]], 2
-; CHECK-NEXT: [[ADD_PTR_SHL:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL]]
-; CHECK-NEXT: [[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL]], [[MAX]]
+; CHECK-NEXT: [[IDX_SHL_1:%.*]] = shl nuw i32 [[IDX]], 1
+; CHECK-NEXT: [[ADD_PTR_SHL_1:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_1]]
+; CHECK-NEXT: [[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL_1]], [[MAX]]
; CHECK-NEXT: call void @use(i1 [[C_MAX_0]])
-; CHECK-NEXT: [[IDX_SHL_NOT_NUW:%.*]] = shl i32 [[IDX]], 2
-; CHECK-NEXT: [[ADD_PTR_SHL_NOT_NUW:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_NOT_NUW]]
-; CHECK-NEXT: [[C_MAX_1:%.*]] = icmp ult i32* [[ADD_PTR_SHL_NOT_NUW]], [[MAX]]
+; CHECK-NEXT: [[IDX_SHL_2:%.*]] = shl nuw i32 [[IDX]], 2
+; CHECK-NEXT: [[ADD_PTR_SHL_2:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_2]]
+; CHECK-NEXT: [[C_MAX_1:%.*]] = icmp ult i32* [[ADD_PTR_SHL_2]], [[MAX]]
; CHECK-NEXT: call void @use(i1 [[C_MAX_1]])
+; CHECK-NEXT: [[IDX_SHL_NOT_NUW:%.*]] = shl i32 [[IDX]], 1
+; CHECK-NEXT: [[ADD_PTR_SHL_NOT_NUW:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_NOT_NUW]]
+; CHECK-NEXT: [[C_MAX_2:%.*]] = icmp ult i32* [[ADD_PTR_SHL_NOT_NUW]], [[MAX]]
+; CHECK-NEXT: call void @use(i1 [[C_MAX_2]])
; CHECK-NEXT: [[IDX_SHL_3:%.*]] = shl nuw i32 [[IDX]], 3
; CHECK-NEXT: [[ADD_PTR_SHL_3:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i32 [[IDX_SHL_3]]
-; CHECK-NEXT: [[C_MAX_2:%.*]] = icmp ult i32* [[ADD_PTR_SHL_3]], [[MAX]]
-; CHECK-NEXT: call void @use(i1 [[C_MAX_2]])
+; CHECK-NEXT: [[C_MAX_3:%.*]] = icmp ult i32* [[ADD_PTR_SHL_3]], [[MAX]]
+; CHECK-NEXT: call void @use(i1 [[C_MAX_3]])
; CHECK-NEXT: ret void
;
check.0.min:
br i1 %cmp, label %check.max, label %trap
check.max: ; preds = %check.0.min
- %idx.shl = shl nuw i32 %idx, 2
- %add.ptr.shl = getelementptr inbounds i32, i32* %src, i32 %idx.shl
- %c.max.0 = icmp ult i32* %add.ptr.shl, %max
+ %idx.shl.1 = shl nuw i32 %idx, 1
+ %add.ptr.shl.1 = getelementptr inbounds i32, i32* %src, i32 %idx.shl.1
+ %c.max.0 = icmp ult i32* %add.ptr.shl.1, %max
call void @use(i1 %c.max.0)
- %idx.shl.not.nuw = shl i32 %idx, 2
- %add.ptr.shl.not.nuw = getelementptr inbounds i32, i32* %src, i32 %idx.shl.not.nuw
- %c.max.1 = icmp ult i32* %add.ptr.shl.not.nuw, %max
+ %idx.shl.2 = shl nuw i32 %idx, 2
+ %add.ptr.shl.2 = getelementptr inbounds i32, i32* %src, i32 %idx.shl.2
+ %c.max.1 = icmp ult i32* %add.ptr.shl.2, %max
call void @use(i1 %c.max.1)
+ %idx.shl.not.nuw = shl i32 %idx, 1
+ %add.ptr.shl.not.nuw = getelementptr inbounds i32, i32* %src, i32 %idx.shl.not.nuw
+ %c.max.2 = icmp ult i32* %add.ptr.shl.not.nuw, %max
+ call void @use(i1 %c.max.2)
+
%idx.shl.3 = shl nuw i32 %idx, 3
%add.ptr.shl.3 = getelementptr inbounds i32, i32* %src, i32 %idx.shl.3
- %c.max.2 = icmp ult i32* %add.ptr.shl.3, %max
- call void @use(i1 %c.max.2)
+ %c.max.3 = icmp ult i32* %add.ptr.shl.3, %max
+ call void @use(i1 %c.max.3)
ret void
}
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[IDX:%.*]], 5
; CHECK-NEXT: br i1 [[CMP]], label [[CHECK_MAX:%.*]], label [[TRAP]]
; CHECK: check.max:
-; CHECK-NEXT: [[IDX_SHL:%.*]] = shl nuw i32 [[IDX]], 2
+; CHECK-NEXT: [[IDX_SHL:%.*]] = shl nuw i32 [[IDX]], 1
; CHECK-NEXT: [[EXT_1:%.*]] = zext i32 [[IDX_SHL]] to i64
; CHECK-NEXT: [[ADD_PTR_SHL:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 [[EXT_1]]
; CHECK-NEXT: [[C_MAX_0:%.*]] = icmp ult i32* [[ADD_PTR_SHL]], [[MAX]]
; CHECK-NEXT: call void @use(i1 [[C_MAX_0]])
-; CHECK-NEXT: [[IDX_SHL_NOT_NUW:%.*]] = shl i32 [[IDX]], 2
+; CHECK-NEXT: [[IDX_SHL_NOT_NUW:%.*]] = shl i32 [[IDX]], 1
; CHECK-NEXT: [[EXT_2:%.*]] = zext i32 [[IDX_SHL_NOT_NUW]] to i64
; CHECK-NEXT: [[ADD_PTR_SHL_NOT_NUW:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 [[EXT_2]]
; CHECK-NEXT: [[C_MAX_1:%.*]] = icmp ult i32* [[ADD_PTR_SHL_NOT_NUW]], [[MAX]]
; CHECK-NEXT: call void @use(i1 [[C_MAX_1]])
-; CHECK-NEXT: [[IDX_SHL_3:%.*]] = shl nuw i32 [[IDX]], 3
+; CHECK-NEXT: [[IDX_SHL_3:%.*]] = shl nuw i32 [[IDX]], 2
; CHECK-NEXT: [[EXT_3:%.*]] = zext i32 [[IDX_SHL_3]] to i64
; CHECK-NEXT: [[ADD_PTR_SHL_3:%.*]] = getelementptr inbounds i32, i32* [[SRC]], i64 [[EXT_3]]
; CHECK-NEXT: [[C_MAX_2:%.*]] = icmp ult i32* [[ADD_PTR_SHL_3]], [[MAX]]
br i1 %cmp, label %check.max, label %trap
check.max: ; preds = %check.0.min
- %idx.shl = shl nuw i32 %idx, 2
+ %idx.shl = shl nuw i32 %idx, 1
%ext.1 = zext i32 %idx.shl to i64
%add.ptr.shl = getelementptr inbounds i32, i32* %src, i64 %ext.1
%c.max.0 = icmp ult i32* %add.ptr.shl, %max
call void @use(i1 %c.max.0)
- %idx.shl.not.nuw = shl i32 %idx, 2
+ %idx.shl.not.nuw = shl i32 %idx, 1
%ext.2 = zext i32 %idx.shl.not.nuw to i64
%add.ptr.shl.not.nuw = getelementptr inbounds i32, i32* %src, i64 %ext.2
%c.max.1 = icmp ult i32* %add.ptr.shl.not.nuw, %max
call void @use(i1 %c.max.1)
- %idx.shl.3 = shl nuw i32 %idx, 3
+ %idx.shl.3 = shl nuw i32 %idx, 2
%ext.3 = zext i32 %idx.shl.3 to i64
%add.ptr.shl.3 = getelementptr inbounds i32, i32* %src, i64 %ext.3
%c.max.2 = icmp ult i32* %add.ptr.shl.3, %max