Author: Nikita Popov Date: 2021-01-17T20:06:17+01:00 New Revision: 1cc477f030bdeb6de98c6bde89fa7850630def24
URL: https://github.com/llvm/llvm-project/commit/1cc477f030bdeb6de98c6bde89fa7850630def24 DIFF: https://github.com/llvm/llvm-project/commit/1cc477f030bdeb6de98c6bde89fa7850630def24.diff LOG: [SimplifyCFG] Add test for PR48778 (NFC) The sdiv is incorrectly speculated. Added: llvm/test/Transforms/SimplifyCFG/pr48778-sdiv-speculation.ll Modified: Removed: ################################################################################ diff --git a/llvm/test/Transforms/SimplifyCFG/pr48778-sdiv-speculation.ll b/llvm/test/Transforms/SimplifyCFG/pr48778-sdiv-speculation.ll new file mode 100644 index 000000000000..992736c48572 --- /dev/null +++ b/llvm/test/Transforms/SimplifyCFG/pr48778-sdiv-speculation.ll @@ -0,0 +1,26 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -simplifycfg -S < %s | FileCheck %s + +; sdiv INT_MIN / -1 should not be speculated. +define i32 @test(i1 %cmp) { +; CHECK-LABEL: @test( +; CHECK-NEXT: else: +; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 -2147483648, -1 +; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[DIV]], 0 +; CHECK-NEXT: [[OR_COND:%.*]] = and i1 [[CMP:%.*]], [[CMP2]] +; CHECK-NEXT: [[MERGE:%.*]] = select i1 [[OR_COND]], i32 1, i32 0 +; CHECK-NEXT: ret i32 [[MERGE]] +; + br i1 %cmp, label %if, label %else + +if: + %div = sdiv i32 -2147483648, -1 + %cmp2 = icmp ne i32 %div, 0 + br i1 %cmp2, label %end, label %else + +else: + ret i32 0 + +end: + ret i32 1 +} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits