@@ -356,7 +356,7 @@ define i1 @test13_i16(i16 %X, ptr %P) {
356356
357357define i1 @test13_i128 (i128 %X , ptr %P ) {
358358; CHECK-LABEL: @test13_i128(
359- ; CHECK-NEXT: [[TMP1:%.*]] = trunc i128 [[X:%.*]] to i64
359+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw i128 [[X:%.*]] to i64
360360; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[TMP1]], -1
361361; CHECK-NEXT: ret i1 [[C]]
362362;
@@ -412,7 +412,7 @@ define ptr @test_index_canon_inbounds(ptr %X, i32 %Idx) {
412412
413413define ptr @test_index_canon_nusw_nuw (ptr %X , i32 %Idx ) {
414414; CHECK-LABEL: @test_index_canon_nusw_nuw(
415- ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[IDX:%.*]] to i64
415+ ; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[IDX:%.*]] to i64
416416; CHECK-NEXT: [[R:%.*]] = getelementptr nusw nuw i32, ptr [[X:%.*]], i64 [[TMP1]]
417417; CHECK-NEXT: ret ptr [[R]]
418418;
@@ -568,7 +568,7 @@ define i32 @test20(ptr %P, i32 %A, i32 %B) {
568568
569569define i32 @test20_as1 (ptr addrspace (1 ) %P , i32 %A , i32 %B ) {
570570; CHECK-LABEL: @test20_as1(
571- ; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[A:%.*]] to i16
571+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw i32 [[A:%.*]] to i16
572572; CHECK-NEXT: [[T6:%.*]] = icmp eq i16 [[TMP1]], 0
573573; CHECK-NEXT: [[T7:%.*]] = zext i1 [[T6]] to i32
574574; CHECK-NEXT: ret i32 [[T7]]
@@ -1978,4 +1978,94 @@ define ptr @gep_merge_nusw_const(ptr %p, i64 %idx, i64 %idx2) {
19781978 ret ptr %gep
19791979}
19801980
1981+ define ptr @gep_index_trunc_nothing (ptr %p , i128 %idx ) {
1982+ ; CHECK-LABEL: @gep_index_trunc_nothing(
1983+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc i128 [[IDX:%.*]] to i64
1984+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[TMP1]]
1985+ ; CHECK-NEXT: ret ptr [[GEP]]
1986+ ;
1987+ %gep = getelementptr i8 , ptr %p , i128 %idx
1988+ ret ptr %gep
1989+ }
1990+
1991+ define ptr @gep_index_trunc_nuw (ptr %p , i128 %idx ) {
1992+ ; CHECK-LABEL: @gep_index_trunc_nuw(
1993+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nuw i128 [[IDX:%.*]] to i64
1994+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nuw i8, ptr [[P:%.*]], i64 [[TMP1]]
1995+ ; CHECK-NEXT: ret ptr [[GEP]]
1996+ ;
1997+ %gep = getelementptr nuw i8 , ptr %p , i128 %idx
1998+ ret ptr %gep
1999+ }
2000+
2001+ define ptr @gep_index_trunc_nusw (ptr %p , i128 %idx ) {
2002+ ; CHECK-LABEL: @gep_index_trunc_nusw(
2003+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw i128 [[IDX:%.*]] to i64
2004+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nusw i8, ptr [[P:%.*]], i64 [[TMP1]]
2005+ ; CHECK-NEXT: ret ptr [[GEP]]
2006+ ;
2007+ %gep = getelementptr nusw i8 , ptr %p , i128 %idx
2008+ ret ptr %gep
2009+ }
2010+
2011+ define ptr @gep_index_trunc_inbounds (ptr %p , i128 %idx ) {
2012+ ; CHECK-LABEL: @gep_index_trunc_inbounds(
2013+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nsw i128 [[IDX:%.*]] to i64
2014+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[P:%.*]], i64 [[TMP1]]
2015+ ; CHECK-NEXT: ret ptr [[GEP]]
2016+ ;
2017+ %gep = getelementptr inbounds i8 , ptr %p , i128 %idx
2018+ ret ptr %gep
2019+ }
2020+
2021+ define ptr @gep_index_trunc_nusw_nuw (ptr %p , i128 %idx ) {
2022+ ; CHECK-LABEL: @gep_index_trunc_nusw_nuw(
2023+ ; CHECK-NEXT: [[TMP1:%.*]] = trunc nuw nsw i128 [[IDX:%.*]] to i64
2024+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nusw nuw i8, ptr [[P:%.*]], i64 [[TMP1]]
2025+ ; CHECK-NEXT: ret ptr [[GEP]]
2026+ ;
2027+ %gep = getelementptr nusw nuw i8 , ptr %p , i128 %idx
2028+ ret ptr %gep
2029+ }
2030+
2031+ define ptr @gep_index_ext_nothing (ptr %p , i32 %idx ) {
2032+ ; CHECK-LABEL: @gep_index_ext_nothing(
2033+ ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[IDX:%.*]] to i64
2034+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[TMP1]]
2035+ ; CHECK-NEXT: ret ptr [[GEP]]
2036+ ;
2037+ %gep = getelementptr i8 , ptr %p , i32 %idx
2038+ ret ptr %gep
2039+ }
2040+
2041+ define ptr @gep_index_ext_nuw (ptr %p , i32 %idx ) {
2042+ ; CHECK-LABEL: @gep_index_ext_nuw(
2043+ ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[IDX:%.*]] to i64
2044+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nuw i8, ptr [[P:%.*]], i64 [[TMP1]]
2045+ ; CHECK-NEXT: ret ptr [[GEP]]
2046+ ;
2047+ %gep = getelementptr nuw i8 , ptr %p , i32 %idx
2048+ ret ptr %gep
2049+ }
2050+
2051+ define ptr @gep_index_ext_nusw (ptr %p , i32 %idx ) {
2052+ ; CHECK-LABEL: @gep_index_ext_nusw(
2053+ ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[IDX:%.*]] to i64
2054+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nuw i8, ptr [[P:%.*]], i64 [[TMP1]]
2055+ ; CHECK-NEXT: ret ptr [[GEP]]
2056+ ;
2057+ %gep = getelementptr nuw i8 , ptr %p , i32 %idx
2058+ ret ptr %gep
2059+ }
2060+
2061+ define ptr @gep_index_ext_nusw_nuw (ptr %p , i32 %idx ) {
2062+ ; CHECK-LABEL: @gep_index_ext_nusw_nuw(
2063+ ; CHECK-NEXT: [[TMP1:%.*]] = zext nneg i32 [[IDX:%.*]] to i64
2064+ ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nusw nuw i8, ptr [[P:%.*]], i64 [[TMP1]]
2065+ ; CHECK-NEXT: ret ptr [[GEP]]
2066+ ;
2067+ %gep = getelementptr nusw nuw i8 , ptr %p , i32 %idx
2068+ ret ptr %gep
2069+ }
2070+
19812071!0 = !{!"branch_weights" , i32 2 , i32 10 }
0 commit comments