@@ -84,6 +84,32 @@ define ptr @test2a(ptr %p, i64 %x, i64 %y) {
8484 ret ptr %select
8585}
8686
87+ define ptr @test2a_nusw (ptr %p , i64 %x , i64 %y ) {
88+ ; CHECK-LABEL: @test2a_nusw(
89+ ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X:%.*]], [[Y:%.*]]
90+ ; CHECK-NEXT: [[SELECT_IDX:%.*]] = select i1 [[CMP]], i64 [[X]], i64 0
91+ ; CHECK-NEXT: [[SELECT:%.*]] = getelementptr nusw i32, ptr [[P:%.*]], i64 [[SELECT_IDX]]
92+ ; CHECK-NEXT: ret ptr [[SELECT]]
93+ ;
94+ %gep = getelementptr nusw i32 , ptr %p , i64 %x
95+ %cmp = icmp ugt i64 %x , %y
96+ %select = select i1 %cmp , ptr %gep , ptr %p
97+ ret ptr %select
98+ }
99+
100+ define ptr @test2a_nuw (ptr %p , i64 %x , i64 %y ) {
101+ ; CHECK-LABEL: @test2a_nuw(
102+ ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i64 [[X:%.*]], [[Y:%.*]]
103+ ; CHECK-NEXT: [[SELECT_IDX:%.*]] = select i1 [[CMP]], i64 [[X]], i64 0
104+ ; CHECK-NEXT: [[SELECT:%.*]] = getelementptr nuw i32, ptr [[P:%.*]], i64 [[SELECT_IDX]]
105+ ; CHECK-NEXT: ret ptr [[SELECT]]
106+ ;
107+ %gep = getelementptr nuw i32 , ptr %p , i64 %x
108+ %cmp = icmp ugt i64 %x , %y
109+ %select = select i1 %cmp , ptr %gep , ptr %p
110+ ret ptr %select
111+ }
112+
87113; PR50183
88114define ptr @test2b (ptr %p , i64 %x , i64 %y ) {
89115; CHECK-LABEL: @test2b(
0 commit comments