[llvm] 6aae8ef - [SCCP] Add a few more additional sext tests (NFC).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 05:40:32 PDT 2020


Author: Florian Hahn
Date: 2020-06-17T13:39:36+01:00
New Revision: 6aae8ef164e6b909adc1a09eda5c48ae6e733f63

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

LOG: [SCCP] Add a few more additional sext tests (NFC).

Added: 
    

Modified: 
    llvm/test/Transforms/SCCP/ip-ranges-sext.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SCCP/ip-ranges-sext.ll b/llvm/test/Transforms/SCCP/ip-ranges-sext.ll
index b631aeca1b5a..eeac47ae572e 100644
--- a/llvm/test/Transforms/SCCP/ip-ranges-sext.ll
+++ b/llvm/test/Transforms/SCCP/ip-ranges-sext.ll
@@ -112,3 +112,26 @@ define i64 @test5(i32 %x) {
   %ext = sext i32 %p to i64
   ret i64 %ext
 }
+
+; sext is constant folded before sext -> zext conversion.
+define i64 @test6(i32 %x) {
+; CHECK-LABEL: @test6(
+; CHECK-NEXT:    ret i64 10
+;
+  %ext = sext i32 10 to i64
+  ret i64 %ext
+}
+
+; sext that can be converted to zext feeds another sext.
+define i64 @test7(i16 %x) {
+; CHECK-LABEL: @test7(
+; CHECK-NEXT:    [[P:%.*]] = and i16 [[X:%.*]], 15
+; CHECK-NEXT:    [[EXT_1:%.*]] = sext i16 [[P]] to i32
+; CHECK-NEXT:    [[EXT_2:%.*]] = sext i32 [[EXT_1]] to i64
+; CHECK-NEXT:    ret i64 [[EXT_2]]
+;
+  %p = and i16 %x, 15
+  %ext.1 = sext i16 %p to i32
+  %ext.2 = sext i32 %ext.1 to i64
+  ret i64 %ext.2
+}


        


More information about the llvm-commits mailing list