[llvm] [CVP] Infer `nuw`/`nsw` flags for TruncInst (PR #130504)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 02:10:55 PDT 2025


================
@@ -0,0 +1,114 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
+
+
+define i1 @infer_nuw(i8 range(i8 0, 2) %A, i8 range(i8 0, 2) %B) {
+; CHECK-LABEL: define i1 @infer_nuw(
+; CHECK-SAME: i8 range(i8 0, 2) [[A:%.*]], i8 range(i8 0, 2) [[B:%.*]]) {
+; CHECK-NEXT:    [[XOR:%.*]] = xor i8 [[B]], [[A]]
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw i8 [[XOR]] to i1
+; CHECK-NEXT:    [[RESULT:%.*]] = xor i1 [[TRUNC]], true
+; CHECK-NEXT:    ret i1 [[RESULT]]
+;
+  %xor = xor i8 %B, %A
+  %trunc = trunc i8 %xor to i1
+  %result = xor i1 %trunc, true
----------------
nikic wrote:

What is the purpose of the trailing xor instructions in the tests?

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


More information about the llvm-commits mailing list