[llvm] 357c339 - [InstCombine][test] add test for potential miscompile with constant expression; NFC (PR50906)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 28 14:00:29 PDT 2021
Author: Sanjay Patel
Date: 2021-06-28T17:00:21-04:00
New Revision: 357c339ec83c94ec83314174553ef8be2bda3c8b
URL: https://github.com/llvm/llvm-project/commit/357c339ec83c94ec83314174553ef8be2bda3c8b
DIFF: https://github.com/llvm/llvm-project/commit/357c339ec83c94ec83314174553ef8be2bda3c8b.diff
LOG: [InstCombine][test] add test for potential miscompile with constant expression; NFC (PR50906)
Added:
Modified:
llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
index 2ca2a45d5c3ff..24410a125d261 100644
--- a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
+++ b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
@@ -249,6 +249,35 @@ bb10:
ret i1 %cmp
}
+; FIXME:
+; It is not generally safe to hoist an expression (sdiv) that may trap.
+
+define i1 @PR50906() {
+; CHECK-LABEL: @PR50906(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: [[CMP:%.*]] = phi i1 [ icmp sgt (i32 sdiv (i32 7, i32 ptrtoint (i1 ()* @PR50906 to i32)), i32 1), [[NEXT:%.*]] ], [ icmp sgt (i32 sdiv (i32 7, i32 ptrtoint (i1 ()* @PR50906 to i32)), i32 0), [[ENTRY:%.*]] ]
+; CHECK-NEXT: br label [[NEXT]]
+; CHECK: next:
+; CHECK-NEXT: br i1 [[CMP]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK: exit:
+; CHECK-NEXT: ret i1 [[CMP]]
+;
+entry:
+ br label %loop
+
+loop:
+ %phi = phi i32 [ 0, %entry ], [ 1, %next ]
+ br label %next
+
+next:
+ %cmp = icmp sgt i32 sdiv (i32 7, i32 ptrtoint (i1 ()* @PR50906 to i32)), %phi
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret i1 %cmp
+}
declare i32 @__gxx_personality_v0(...)
More information about the llvm-commits
mailing list