[llvm] cf90233 - [InstCombine] Add additional test for icmp of two ranges (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 02:14:23 PDT 2022


Author: Nikita Popov
Date: 2022-04-29T11:14:15+02:00
New Revision: cf90233a67eb513930880ff1b49e80af18de5d5c

URL: https://github.com/llvm/llvm-project/commit/cf90233a67eb513930880ff1b49e80af18de5d5c
DIFF: https://github.com/llvm/llvm-project/commit/cf90233a67eb513930880ff1b49e80af18de5d5c.diff

LOG: [InstCombine] Add additional test for icmp of two ranges (NFC)

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/or.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll
index b1ff6830a378..e1523448ff7c 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -813,6 +813,24 @@ define <2 x i1> @test46_undef(<2 x i8> %c)  {
   ret <2 x i1> %or
 }
 
+; This is the variant of the above pattern where one of the ranges is
+; represented with an add.
+define i1 @two_ranges_to_mask_and_range_degenerate(i16 %x) {
+; CHECK-LABEL: @two_ranges_to_mask_and_range_degenerate(
+; CHECK-NEXT:    [[CMP1:%.*]] = icmp ult i16 [[X:%.*]], 12
+; CHECK-NEXT:    [[TMP1:%.*]] = add i16 [[X]], -16
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult i16 [[TMP1]], 12
+; CHECK-NEXT:    [[OR:%.*]] = or i1 [[CMP1]], [[TMP2]]
+; CHECK-NEXT:    ret i1 [[OR]]
+;
+  %cmp1 = icmp ult i16 %x, 12
+  %cmp2 = icmp uge i16 %x, 16
+  %cmp3 = icmp ult i16 %x, 28
+  %and = and i1 %cmp2, %cmp3
+  %or = or i1 %cmp1, %and
+  ret i1 %or
+}
+
 define i1 @test47(i8 signext %c)  {
 ; CHECK-LABEL: @test47(
 ; CHECK-NEXT:    [[TMP1:%.*]] = and i8 [[C:%.*]], -33


        


More information about the llvm-commits mailing list