[llvm] r370414 - [Tests] Precommit a few cases where we're missing oppurtunities for block local simplications off assumes.
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 15:08:17 PDT 2019
Author: reames
Date: Thu Aug 29 15:08:17 2019
New Revision: 370414
URL: http://llvm.org/viewvc/llvm-project?rev=370414&view=rev
Log:
[Tests] Precommit a few cases where we're missing oppurtunities for block local simplications off assumes.
Added:
llvm/trunk/test/Transforms/GVN/equality-assume.ll
Added: llvm/trunk/test/Transforms/GVN/equality-assume.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/equality-assume.ll?rev=370414&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVN/equality-assume.ll (added)
+++ llvm/trunk/test/Transforms/GVN/equality-assume.ll Thu Aug 29 15:08:17 2019
@@ -0,0 +1,66 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -gvn < %s | FileCheck %s
+
+define i32 @test(i32* %p, i32 %v) {
+; CHECK-LABEL: @test(
+; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[P:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[LOAD]], [[V:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
+; CHECK-NEXT: ret i32 [[LOAD]]
+;
+ %load = load i32, i32* %p
+ %c = icmp eq i32 %load, %v
+ call void @llvm.assume(i1 %c)
+ ret i32 %load
+}
+
+define i32 @reverse(i32* %p, i32 %v) {
+; CHECK-LABEL: @reverse(
+; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[P:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[LOAD]], [[V:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %load = load i32, i32* %p
+ %c = icmp eq i32 %load, %v
+ call void @llvm.assume(i1 %c)
+ ret i32 %v
+}
+
+define i32 @test2(i32* %p, i32 %v) {
+; CHECK-LABEL: @test2(
+; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[P:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[LOAD]], [[V:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
+; CHECK-NEXT: ret i32 [[LOAD]]
+;
+ %load = load i32, i32* %p
+ %c = icmp eq i32 %load, %v
+ call void @llvm.assume(i1 %c)
+ %load2 = load i32, i32* %p
+ ret i32 %load2
+}
+
+define i32 @test3(i32* %p, i32 %v) {
+; CHECK-LABEL: @test3(
+; CHECK-NEXT: [[LOAD:%.*]] = load i32, i32* [[P:%.*]]
+; CHECK-NEXT: [[C:%.*]] = icmp eq i32 [[LOAD]], [[V:%.*]]
+; CHECK-NEXT: call void @llvm.assume(i1 [[C]])
+; CHECK-NEXT: br i1 undef, label [[TAKEN:%.*]], label [[MERGE:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: br label [[MERGE]]
+; CHECK: merge:
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %load = load i32, i32* %p
+ %c = icmp eq i32 %load, %v
+ call void @llvm.assume(i1 %c)
+ br i1 undef, label %taken, label %merge
+taken:
+ br label %merge
+merge:
+ ret i32 %load
+}
+
+
+declare void @llvm.assume(i1)
More information about the llvm-commits
mailing list