| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt -passes=instcombine -S < %s | FileCheck %s |
| |
| ; pdep(x, 0b11110000): bits 0..3 of result are always zero. |
| define i1 @pdep_low_bits_zero(i8 %x) nounwind { |
| ; CHECK-LABEL: @pdep_low_bits_zero( |
| ; CHECK-NEXT: ret i1 true |
| ; |
| %pdep = call i8 @llvm.pdep.i8(i8 %x, i8 240) |
| %and = and i8 %pdep, 15 |
| %r = icmp eq i8 %and, 0 |
| ret i1 %r |
| } |
| |
| define <2 x i1> @pdep_low_bits_zero_vector(<2 x i8> %x) nounwind { |
| ; CHECK-LABEL: @pdep_low_bits_zero_vector( |
| ; CHECK-NEXT: ret <2 x i1> splat (i1 true) |
| ; |
| %pdep = call <2 x i8> @llvm.pdep.v2i8(<2 x i8> %x, <2 x i8> splat (i8 -16)) |
| %and = and <2 x i8> %pdep, splat (i8 15) |
| %r = icmp eq <2 x i8> %and, zeroinitializer |
| ret <2 x i1> %r |
| } |
| |
| ; pdep(x, 0b00001111): bits 4..7 of result are always zero. |
| define i1 @pdep_high_bits_zero(i8 %x) nounwind { |
| ; CHECK-LABEL: @pdep_high_bits_zero( |
| ; CHECK-NEXT: ret i1 true |
| ; |
| %pdep = call i8 @llvm.pdep.i8(i8 %x, i8 15) |
| %and = and i8 %pdep, 240 |
| %r = icmp eq i8 %and, 0 |
| ret i1 %r |
| } |
| |
| define <2 x i1> @pdep_high_bits_zero_vector(<2 x i8> %x) nounwind { |
| ; CHECK-LABEL: @pdep_high_bits_zero_vector( |
| ; CHECK-NEXT: ret <2 x i1> splat (i1 true) |
| ; |
| %pdep = call <2 x i8> @llvm.pdep.v2i8(<2 x i8> %x, <2 x i8> splat (i8 15)) |
| %and = and <2 x i8> %pdep, splat (i8 240) |
| %r = icmp eq <2 x i8> %and, zeroinitializer |
| ret <2 x i1> %r |
| } |
| |
| ; pdep(x, 0) -> all bits zero. |
| define i1 @pdep_zero_mask_known_zero(i8 %x) nounwind { |
| ; CHECK-LABEL: @pdep_zero_mask_known_zero( |
| ; CHECK-NEXT: ret i1 true |
| ; |
| %pdep = call i8 @llvm.pdep.i8(i8 %x, i8 0) |
| %r = icmp eq i8 %pdep, 0 |
| ret i1 %r |
| } |
| |
| define <2 x i1> @pdep_zero_mask_known_zero_vector(<2 x i8> %x) nounwind { |
| ; CHECK-LABEL: @pdep_zero_mask_known_zero_vector( |
| ; CHECK-NEXT: ret <2 x i1> splat (i1 true) |
| ; |
| %pdep = call <2 x i8> @llvm.pdep.v2i8(<2 x i8> %x, <2 x i8> zeroinitializer) |
| %r = icmp eq <2 x i8> %pdep, zeroinitializer |
| ret <2 x i1> %r |
| } |
| |
| ; Negative: pdep(x, 0b11001100) can have bits 2,3,6,7 set. |
| ; Sign bit may be set, but known bits analysis can narrow the range. |
| define i1 @pdep_mask_bits_not_known(i8 %x) nounwind { |
| ; CHECK-LABEL: @pdep_mask_bits_not_known( |
| ; CHECK-NEXT: [[PDEP:%.*]] = call i8 @llvm.pdep.i8(i8 [[X:%.*]], i8 -52) |
| ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[PDEP]], -1 |
| ; CHECK-NEXT: ret i1 [[R]] |
| ; |
| %pdep = call i8 @llvm.pdep.i8(i8 %x, i8 204) |
| %and = and i8 %pdep, 128 |
| %r = icmp eq i8 %and, 0 |
| ret i1 %r |
| } |
| |
| define <2 x i1> @pdep_mask_bits_not_known_vector(<2 x i8> %x) nounwind { |
| ; CHECK-LABEL: @pdep_mask_bits_not_known_vector( |
| ; CHECK-NEXT: [[PDEP:%.*]] = call <2 x i8> @llvm.pdep.v2i8(<2 x i8> [[X:%.*]], <2 x i8> splat (i8 -52)) |
| ; CHECK-NEXT: [[R:%.*]] = icmp sgt <2 x i8> [[PDEP]], splat (i8 -1) |
| ; CHECK-NEXT: ret <2 x i1> [[R]] |
| ; |
| %pdep = call <2 x i8> @llvm.pdep.v2i8(<2 x i8> %x, <2 x i8> splat (i8 -52)) |
| %and = and <2 x i8> %pdep, splat (i8 128) |
| %r = icmp eq <2 x i8> %and, zeroinitializer |
| ret <2 x i1> %r |
| } |