xref: /llvm-project/llvm/test/Analysis/ValueTracking/known-bits.ll (revision 38fffa630ee80163dc65e759392ad29798905679)
141b876dbSNoah Goldstein; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
241b876dbSNoah Goldstein; RUN: opt -passes=instsimplify < %s -S | FileCheck %s
341b876dbSNoah Goldstein
441b876dbSNoah Goldsteindefine <4 x i1> @vec_reverse_known_bits(<4 x i8> %xx) {
541b876dbSNoah Goldstein; CHECK-LABEL: @vec_reverse_known_bits(
6*38fffa63SPaul Walker; CHECK-NEXT:    ret <4 x i1> splat (i1 true)
741b876dbSNoah Goldstein;
841b876dbSNoah Goldstein  %x = or <4 x i8> %xx, <i8 128, i8 128, i8 128, i8 128>
941b876dbSNoah Goldstein  %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
1041b876dbSNoah Goldstein  %r = icmp slt <4 x i8> %rev, zeroinitializer
1141b876dbSNoah Goldstein  ret <4 x i1> %r
1241b876dbSNoah Goldstein}
1341b876dbSNoah Goldstein
1441b876dbSNoah Goldsteindefine <4 x i1> @vec_reverse_known_bits_fail(<4 x i8> %xx) {
1541b876dbSNoah Goldstein; CHECK-LABEL: @vec_reverse_known_bits_fail(
1641b876dbSNoah Goldstein; CHECK-NEXT:    [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 -128, i8 -128, i8 -128, i8 127>
1741b876dbSNoah Goldstein; CHECK-NEXT:    [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
1841b876dbSNoah Goldstein; CHECK-NEXT:    [[R:%.*]] = icmp slt <4 x i8> [[REV]], zeroinitializer
1941b876dbSNoah Goldstein; CHECK-NEXT:    ret <4 x i1> [[R]]
2041b876dbSNoah Goldstein;
2141b876dbSNoah Goldstein  %x = or <4 x i8> %xx, <i8 128, i8 128, i8 128, i8 127>
2241b876dbSNoah Goldstein  %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
2341b876dbSNoah Goldstein  %r = icmp slt <4 x i8> %rev, zeroinitializer
2441b876dbSNoah Goldstein  ret <4 x i1> %r
2541b876dbSNoah Goldstein}
261dfbd072SNoah Goldstein
271dfbd072SNoah Goldsteindefine i1 @vec_reverse_known_bits_demanded(<4 x i8> %xx) {
281dfbd072SNoah Goldstein; CHECK-LABEL: @vec_reverse_known_bits_demanded(
296ef970b6SNoah Goldstein; CHECK-NEXT:    ret i1 true
301dfbd072SNoah Goldstein;
311dfbd072SNoah Goldstein  %x = or <4 x i8> %xx, <i8 127, i8 55, i8 128, i8 123>
321dfbd072SNoah Goldstein  %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
331dfbd072SNoah Goldstein  %ele = extractelement <4 x i8> %rev, i64 1
341dfbd072SNoah Goldstein  %r = icmp slt i8 %ele, 0
351dfbd072SNoah Goldstein  ret i1 %r
361dfbd072SNoah Goldstein}
371dfbd072SNoah Goldstein
381dfbd072SNoah Goldsteindefine i1 @vec_reverse_known_bits_demanded_fail(<4 x i8> %xx) {
391dfbd072SNoah Goldstein; CHECK-LABEL: @vec_reverse_known_bits_demanded_fail(
401dfbd072SNoah Goldstein; CHECK-NEXT:    [[X:%.*]] = or <4 x i8> [[XX:%.*]], <i8 127, i8 55, i8 -128, i8 123>
411dfbd072SNoah Goldstein; CHECK-NEXT:    [[REV:%.*]] = call <4 x i8> @llvm.vector.reverse.v4i8(<4 x i8> [[X]])
421dfbd072SNoah Goldstein; CHECK-NEXT:    [[ELE:%.*]] = extractelement <4 x i8> [[REV]], i64 2
431dfbd072SNoah Goldstein; CHECK-NEXT:    [[R:%.*]] = icmp slt i8 [[ELE]], 0
441dfbd072SNoah Goldstein; CHECK-NEXT:    ret i1 [[R]]
451dfbd072SNoah Goldstein;
461dfbd072SNoah Goldstein  %x = or <4 x i8> %xx, <i8 127, i8 55, i8 128, i8 123>
471dfbd072SNoah Goldstein  %rev = call <4 x i8> @llvm.vector.reverse(<4 x i8> %x)
481dfbd072SNoah Goldstein  %ele = extractelement <4 x i8> %rev, i64 2
491dfbd072SNoah Goldstein  %r = icmp slt i8 %ele, 0
501dfbd072SNoah Goldstein  ret i1 %r
511dfbd072SNoah Goldstein}
52