[llvm] 87f3ebd - [InstCombine] add test for bogus bswap; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 23 08:28:46 PDT 2022


Author: Sanjay Patel
Date: 2022-03-23T11:28:37-04:00
New Revision: 87f3ebd505864a4a28c476fa63fc38a334bec1f9

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

LOG: [InstCombine] add test for bogus bswap; NFC

This is reduced from a crash caused by D122166.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/lshr.ll b/llvm/test/Transforms/InstCombine/lshr.ll
index 175430189ce12..34a5facceafd5 100644
--- a/llvm/test/Transforms/InstCombine/lshr.ll
+++ b/llvm/test/Transforms/InstCombine/lshr.ll
@@ -919,3 +919,16 @@ define i128 @narrow_bswap_overshift2(i96 %x) {
   %s = lshr i128 %b, 61
   ret i128 %s
 }
+
+define i32 @not_narrow_bswap(i24 %x) {
+; CHECK-LABEL: @not_narrow_bswap(
+; CHECK-NEXT:    [[Z:%.*]] = zext i24 [[X:%.*]] to i32
+; CHECK-NEXT:    [[B:%.*]] = call i32 @llvm.bswap.i32(i32 [[Z]])
+; CHECK-NEXT:    [[R:%.*]] = lshr exact i32 [[B]], 8
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %z = zext i24 %x to i32
+  %b = call i32 @llvm.bswap.i32(i32 %z)
+  %r = lshr i32 %b, 8
+  ret i32 %r
+}


        


More information about the llvm-commits mailing list