From 5ea2d55e1c138cb04f87993dfdfe3f1edeb96e1f Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 1 Jun 2017 21:20:07 +0000 Subject: [PATCH] [InstSimplify][ConstantFolding] Add test demonstrating failure to simplify (icmp eq null, inttoptr x) when the null is on the left hand side. NFC llvm-svn: 304474 --- llvm/test/Transforms/InstSimplify/compare.ll | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll index d6f1b634102f..9125367a7bf9 100644 --- a/llvm/test/Transforms/InstSimplify/compare.ll +++ b/llvm/test/Transforms/InstSimplify/compare.ll @@ -1278,3 +1278,19 @@ define void @icmp_slt_sge_or(i32 %Ax, i32 %Bx) { ; CHECK: call void @helper_i1(i1 true) ret void } + +define i1 @constant_fold_inttoptr_null() { +; CHECK-LABEL: @constant_fold_inttoptr_null( +; CHECK-NEXT: ret i1 false +; + %x = icmp eq i32* inttoptr (i64 32 to i32*), null + ret i1 %x +} + +define i1 @constant_fold_null_inttoptr() { +; CHECK-LABEL: @constant_fold_null_inttoptr( +; CHECK-NEXT: ret i1 icmp eq (i32* inttoptr (i64 32 to i32*), i32* null) +; + %x = icmp eq i32* null, inttoptr (i64 32 to i32*) + ret i1 %x +}