| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt < %s -passes=instcombine -S | FileCheck %s | |
| define i32 @test_pext_32_zero_src(i32 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_zero_src( | |
| ; CHECK-NEXT: ret i32 0 | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 0, i32 %x) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_zero_src(i64 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_zero_src( | |
| ; CHECK-NEXT: ret i64 0 | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 0, i64 %x) | |
| ret i64 %1 | |
| } | |
| define i32 @test_pext_32_zero_mask(i32 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_zero_mask( | |
| ; CHECK-NEXT: ret i32 0 | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 %x, i32 0) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_zero_mask(i64 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_zero_mask( | |
| ; CHECK-NEXT: ret i64 0 | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 %x, i64 0) | |
| ret i64 %1 | |
| } | |
| define i32 @test_pext_32_allones_mask(i32 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_allones_mask( | |
| ; CHECK-NEXT: ret i32 [[TMP1:%.*]] | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 %x, i32 -1) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_allones_mask(i64 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_allones_mask( | |
| ; CHECK-NEXT: ret i64 [[TMP1:%.*]] | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 %x, i64 -1) | |
| ret i64 %1 | |
| } | |
| define i32 @test_pext_32_shifted_mask(i32 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_shifted_mask( | |
| ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[X:%.*]], 1 | |
| ; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[TMP2]], 3 | |
| ; CHECK-NEXT: ret i32 [[TMP1]] | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 %x, i32 6) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_shifted_mask(i64 %x) nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_shifted_mask( | |
| ; CHECK-NEXT: [[TMP2:%.*]] = lshr i64 [[X:%.*]], 1 | |
| ; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP2]], 3 | |
| ; CHECK-NEXT: ret i64 [[TMP1]] | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 %x, i64 6) | |
| ret i64 %1 | |
| } | |
| define i32 @test_pext_32_constant_fold() nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_constant_fold( | |
| ; CHECK-NEXT: ret i32 30001 | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 1985229328, i32 4042322160) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_constant_fold() nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_constant_fold( | |
| ; CHECK-NEXT: ret i64 1966210489 | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 8526495043095935640, i64 -1085102592571150096) | |
| ret i64 %1 | |
| } | |
| define i32 @test_pext_32_constant_fold_2() nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_32_constant_fold_2( | |
| ; CHECK-NEXT: ret i32 30224 | |
| ; | |
| %1 = tail call i32 @llvm.pext.i32(i32 1985229328, i32 4278190335) | |
| ret i32 %1 | |
| } | |
| define i64 @test_pext_64_constant_fold_2() nounwind readnone { | |
| ; CHECK-LABEL: @test_pext_64_constant_fold_2( | |
| ; CHECK-NEXT: ret i64 1980816570 | |
| ; | |
| %1 = tail call i64 @llvm.pext.i64(i64 8526495043095935640, i64 -72056498804490496) | |
| ret i64 %1 | |
| } | |