[llvm] 89f2fee - [InstCombine] Add test for incorrect retention of Range attribute in fshl

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 25 13:17:21 PST 2025


Author: Fangrui Song
Date: 2025-01-25T13:17:15-08:00
New Revision: 89f2fee9f80658650524ba4fc12f01409e45000e

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

LOG: [InstCombine] Add test for incorrect retention of Range attribute in fshl

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/fsh.ll b/llvm/test/Transforms/InstCombine/fsh.ll
index 236c69e7a5bcb7..34648d586300f0 100644
--- a/llvm/test/Transforms/InstCombine/fsh.ll
+++ b/llvm/test/Transforms/InstCombine/fsh.ll
@@ -1068,3 +1068,18 @@ entry:
   %res = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> %x, <2 x i31> zeroinitializer, <2 x i31>  %y)
   ret <2 x i31>  %res
 }
+
+define i8 @fshl_range_trunc(i1 %x) {
+; CHECK-LABEL: @fshl_range_trunc(
+; CHECK-NEXT:    [[ZEXT:%.*]] = zext i1 [[X:%.*]] to i32
+; CHECK-NEXT:    [[OR:%.*]] = or disjoint i32 [[ZEXT]], 126
+; CHECK-NEXT:    [[FSHL:%.*]] = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 [[OR]], i32 -2, i32 1)
+; CHECK-NEXT:    [[TR:%.*]] = trunc nuw i32 [[FSHL]] to i8
+; CHECK-NEXT:    ret i8 [[TR]]
+;
+  %zext = zext i1 %x to i32
+  %or = or disjoint i32 %zext, -2
+  %fshl = call range(i32 -4, 2) i32 @llvm.fshl.i32(i32 %or, i32 %or, i32 1)
+  %tr = trunc nsw i32 %fshl to i8
+  ret i8 %tr
+}


        


More information about the llvm-commits mailing list