diff options
| author | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-10-25 16:32:28 +0100 |
|---|---|---|
| committer | Tim Diekmann <tim.diekmann@3dvision.de> | 2020-10-25 16:32:28 +0100 |
| commit | 06e4497a04615ad95dff4240ca9980f19ed364ad (patch) | |
| tree | 123a17d04628e05bb2448d1d3e3f11e60f240304 /src/test/codegen | |
| parent | 693a2bf18b7090202784f561de3dfca45c4f79be (diff) | |
| parent | f392479de6b003e72f93cb8f9955b3cf4135c2cd (diff) | |
| download | rust-06e4497a04615ad95dff4240ca9980f19ed364ad.tar.gz rust-06e4497a04615ad95dff4240ca9980f19ed364ad.zip | |
Merge remote-tracking branch 'upstream/master' into box-alloc
Diffstat (limited to 'src/test/codegen')
| -rw-r--r-- | src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs | 18 | ||||
| -rw-r--r-- | src/test/codegen/loop.rs | 15 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs new file mode 100644 index 00000000000..d07eaa75b7a --- /dev/null +++ b/src/test/codegen/issue-73827-bounds-check-index-in-subexpr.rs @@ -0,0 +1,18 @@ +// This test checks that bounds checks are elided when +// index is part of a (x | y) < C style condition + +// min-llvm-version: 11.0.0 +// compile-flags: -O + +#![crate_type = "lib"] + +// CHECK-LABEL: @get +#[no_mangle] +pub fn get(array: &[u8; 8], x: usize, y: usize) -> u8 { + if x > 7 || y > 7 { + 0 + } else { + // CHECK-NOT: panic_bounds_check + array[y] + } +} diff --git a/src/test/codegen/loop.rs b/src/test/codegen/loop.rs new file mode 100644 index 00000000000..e54298eed05 --- /dev/null +++ b/src/test/codegen/loop.rs @@ -0,0 +1,15 @@ +// compile-flags: -C opt-level=3 + +#![crate_type = "lib"] + +// CHECK-LABEL: @check_loop +#[no_mangle] +pub fn check_loop() -> u8 { + // CHECK-NOT: unreachable + call_looper() +} + +#[no_mangle] +fn call_looper() -> ! { + loop {} +} |
