[llvm] 216d1a7 - [GVN] Add tests for D118143 not requiring loops.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 12:24:54 PST 2022
Author: Florian Hahn
Date: 2022-02-01T20:24:19Z
New Revision: 216d1a729c7f7659e9b7c0fb501fcf7d0d572c7d
URL: https://github.com/llvm/llvm-project/commit/216d1a729c7f7659e9b7c0fb501fcf7d0d572c7d
DIFF: https://github.com/llvm/llvm-project/commit/216d1a729c7f7659e9b7c0fb501fcf7d0d572c7d.diff
LOG: [GVN] Add tests for D118143 not requiring loops.
Added:
llvm/test/Transforms/GVN/PRE/pre-load-through-select.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/PRE/pre-load-through-select.ll b/llvm/test/Transforms/GVN/PRE/pre-load-through-select.ll
new file mode 100644
index 0000000000000..693324998e4f9
--- /dev/null
+++ b/llvm/test/Transforms/GVN/PRE/pre-load-through-select.ll
@@ -0,0 +1,465 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -passes='require<domtree>,loop(loop-simplifycfg),gvn' -S %s | FileCheck %s
+
+define i32 @test_pointer_phi_select_simp_1(i32* %a, i32* %b, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_no_load_for_select_op_1(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_no_load_for_select_op_1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A:%.*]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %c, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_no_load_for_select_op_2(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_no_load_for_select_op_2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B:%.*]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %c, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_noclobber(i32* %a, i32* %b, i32* noalias %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_noclobber(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ store i32 99, i32* %c
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_1(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ store i32 99, i32* %c
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_2(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ store i32 99, i32* %c
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_3(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ store i32 99, i32* %c
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_4(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ store i32 99, i32* %c
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_5(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_5(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[RES_2:%.*]] = load i32, i32* [[P]], align 4
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ store i32 99, i32* %c
+ %res.2 = load i32, i32* %p, align 4
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_simp_store_clobber_6(i32* %a, i32* %b, i32* %c, i1 %cond) {
+; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_6(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
+; CHECK: then:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: [[RES_0:%.*]] = load i32, i32* [[MIN_SELECT]], align 4
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: else:
+; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, i32* [[A]], align 4
+; CHECK-NEXT: br label [[EXIT]]
+; CHECK: exit:
+; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
+; CHECK-NEXT: [[P:%.*]] = phi i32* [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
+; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ 10, [[ELSE]] ]
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
+; CHECK-NEXT: ret i32 [[RES_2]]
+;
+entry:
+ br i1 %cond, label %then, label %else
+
+then:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ store i32 99, i32* %c
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ %res.0 = load i32, i32* %min.select, align 4
+ br label %exit
+
+else:
+ br label %exit
+
+exit:
+ %p = phi i32* [ %min.select, %then ], [ %a, %else ]
+ %v = phi i32 [ %res.0, %then ], [ 10, %else ]
+ %res.2 = load i32, i32* %p, align 4
+ %add = add i32 %res.2, %v
+ ret i32 %res.2
+}
+
+define i32 @test_pointer_phi_select_single_block_store(i32* %a, i32* %b) {
+; CHECK-LABEL: @test_pointer_phi_select_single_block_store(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: [[RES_0:%.*]] = load i32, i32* [[MIN_SELECT]], align 4
+; CHECK-NEXT: ret i32 [[RES_0]]
+;
+entry:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ %res.0 = load i32, i32* %min.select, align 4
+ ret i32 %res.0
+}
+
+define i32 @test_pointer_phi_select_single_block_store_clobber_1(i32* %a, i32* %b, i32* %c) {
+; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: [[RES_0:%.*]] = load i32, i32* [[MIN_SELECT]], align 4
+; CHECK-NEXT: ret i32 [[RES_0]]
+;
+entry:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ store i32 99, i32* %c
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ %res.0 = load i32, i32* %min.select, align 4
+ ret i32 %res.0
+}
+
+define i32 @test_pointer_phi_select_single_block_store_clobber_2(i32* %a, i32* %b, i32* %c) {
+; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[RES_0:%.*]] = load i32, i32* [[MIN_SELECT]], align 4
+; CHECK-NEXT: ret i32 [[RES_0]]
+;
+entry:
+ %l.1 = load i32, i32* %a, align 4
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ store i32 99, i32* %c
+ %res.0 = load i32, i32* %min.select, align 4
+ ret i32 %res.0
+}
+
+define i32 @test_pointer_phi_select_single_block_store_clobber_3(i32* %a, i32* %b, i32* %c) {
+; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[L_1:%.*]] = load i32, i32* [[A:%.*]], align 4
+; CHECK-NEXT: store i32 99, i32* [[C:%.*]], align 4
+; CHECK-NEXT: [[L_2:%.*]] = load i32, i32* [[B:%.*]], align 4
+; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
+; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], i32* [[A]], i32* [[B]]
+; CHECK-NEXT: [[RES_0:%.*]] = load i32, i32* [[MIN_SELECT]], align 4
+; CHECK-NEXT: ret i32 [[RES_0]]
+;
+entry:
+ %l.1 = load i32, i32* %a, align 4
+ store i32 99, i32* %c
+ %l.2 = load i32, i32* %b, align 4
+ %cmp.i.i.i = icmp ult i32 %l.1, %l.2
+ %min.select = select i1 %cmp.i.i.i, i32* %a, i32* %b
+ %res.0 = load i32, i32* %min.select, align 4
+ ret i32 %res.0
+}
More information about the llvm-commits
mailing list