1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
4 ; The sub nuw produces poison if the input is not 0 or 1. We must insert a
5 ; freeze before converting the sub to AND so that we don't propagate poison.
6 define i64 @foo(i64 %1) {
8 ; CHECK: # %bb.0: # %entry
10 ; CHECK-NEXT: sub a1, a1, a0
11 ; CHECK-NEXT: sltiu a0, a0, 2
12 ; CHECK-NEXT: xori a1, a1, 1
13 ; CHECK-NEXT: neg a0, a0
14 ; CHECK-NEXT: and a0, a0, a1
17 %.urem.i = sub nuw i64 1, %1
18 %.cmp.i = icmp ugt i64 %1, 1
19 %2 = xor i64 %.urem.i, 1
20 %3 = select i1 %.cmp.i, i64 0, i64 %2