1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4 ;; fold (sext (not x)) -> (add (zext x) -1)
5 define i32 @sext_of_not(i1 %x) {
6 ; CHECK-LABEL: sext_of_not:
8 ; CHECK-NEXT: nilf %r2, 1
9 ; CHECK-NEXT: ahi %r2, -1
12 %sext = sext i1 %xor to i32
16 ;; fold (sext (not (setcc a, b, cc))) -> (sext (setcc a, b, !cc))
17 define i32 @sext_of_not_cmp(i32 %x) {
18 ; CHECK-LABEL: sext_of_not_cmp:
20 ; CHECK-NEXT: chi %r2, 7
22 ; CHECK-NEXT: afi %r2, 1879048192
23 ; CHECK-NEXT: sra %r2, 31
25 %cmp = icmp eq i32 %x, 7
27 %sext = sext i1 %xor to i32
31 ;; fold (sext (not (setcc a, b, cc))) -> (sext (setcc a, b, !cc))
32 ;; make sure we don't crash if the not gets replaced in-visit
33 define i32 @sext_of_not_fsetccs(double %x) strictfp {
34 ; CHECK-LABEL: sext_of_not_fsetccs:
36 ; CHECK-NEXT: ltdbr %f0, %f0
38 ; CHECK-NEXT: afi %r0, 1879048192
39 ; CHECK-NEXT: srl %r0, 31
40 ; CHECK-NEXT: lcr %r2, %r0
42 %cmp = call i1 @llvm.experimental.constrained.fcmp.f64(double %x, double 0.000000e+00, metadata !"oeq", metadata !"fpexcept.ignore")
44 %sext = sext i1 %xor to i32
48 declare i1 @llvm.experimental.constrained.fcmp.f64(double, double, metadata, metadata)
50 ;; TODO: fold (add (zext (setcc a, b, cc)), -1) -> (sext (setcc a, b, !cc))
51 define i32 @dec_of_zexted_cmp(i32 %x) {
52 ; CHECK-LABEL: dec_of_zexted_cmp:
54 ; CHECK-NEXT: chi %r2, 7
56 ; CHECK-NEXT: afi %r2, -268435456
57 ; CHECK-NEXT: srl %r2, 31
58 ; CHECK-NEXT: ahi %r2, -1
60 %cmp = icmp eq i32 %x, 7
61 %zext = zext i1 %cmp to i32
62 %dec = sub i32 %zext, 1