[llvm] [IR] Add nowrap flags for trunc instruction (PR #85592)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 28 02:28:53 PDT 2024


================
@@ -1138,15 +1138,26 @@ define i32 @propagate_drop_flags_or(i32 %arg) {
   ret i32 %v1.fr
 }
 
+define i32 @propagate_drop_flags_trunc(i64 %arg) {
+; CHECK-LABEL: @propagate_drop_flags_trunc(
+; CHECK-NEXT:    [[ARG_FR:%.*]] = freeze i64 [[ARG:%.*]]
+; CHECK-NEXT:    [[V1:%.*]] = trunc i64 [[ARG_FR]] to i32
+; CHECK-NEXT:    ret i32 [[V1]]
+;
+  %v1 = trunc nsw nuw i64 %arg to i32
+  %v1.fr = freeze i32 %v1
+  ret i32 %v1.fr
+}
+
 !0 = !{}
 !1 = !{i64 4}
 !2 = !{i32 0, i32 100}
 ;.
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
 ; CHECK: attributes #[[ATTR1]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = !{}
-; CHECK: [[META1:![0-9]+]] = !{i64 4}
----------------
dtcxzyw wrote:

> @goldsteinn Should I rebase to the last commit in the trunk, and regenerate the tests?

I think what goldsteinn said is to regenerate this test with the trunk and open a separate NFC PR.


https://github.com/llvm/llvm-project/pull/85592


More information about the llvm-commits mailing list