|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt < %s -mergeicmps -mtriple=x86_64-unknown-unknown -S | FileCheck %s |
| 3 | + |
| 4 | +%"struct.std::pair" = type { i32, i32 } |
| 5 | + |
| 6 | +; Check that the transformation is avoided when GEP has a use outside of the |
| 7 | +; parant block of the load instruction. |
| 8 | + |
| 9 | +define zeroext i32 @opeq1( |
| 10 | +; CHECK-LABEL: @opeq1( |
| 11 | +; CHECK-NOT: [[MEMCMP:%.*]] = call i32 @memcmp |
| 12 | + |
| 13 | + %"struct.std::pair"* nocapture readonly dereferenceable(16) %a, |
| 14 | + %"struct.std::pair"* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 { |
| 15 | +entry: |
| 16 | + %first.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 1 |
| 17 | + %0 = load i32, i32* %first.i, align 4 |
| 18 | + %first1.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 1 |
| 19 | + %1 = load i32, i32* %first1.i, align 4 |
| 20 | + %cmp.i = icmp eq i32 %0, %1 |
| 21 | + br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit |
| 22 | + |
| 23 | +land.rhs.i: |
| 24 | + %second.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %a, i64 0, i32 0 |
| 25 | + %2 = load i32, i32* %second.i, align 4 |
| 26 | + %second2.i = getelementptr inbounds %"struct.std::pair", %"struct.std::pair"* %b, i64 0, i32 0 |
| 27 | + %3 = load i32, i32* %second2.i, align 4 |
| 28 | + %cmp3.i = icmp eq i32 %2, %3 |
| 29 | + br label %opeq1.exit |
| 30 | + |
| 31 | +opeq1.exit: |
| 32 | + %4 = phi i1 [ false, %entry ], [ %cmp3.i, %land.rhs.i] |
| 33 | + %5 = load i32, i32* %first.i, align 4 |
| 34 | + %6 = select i1 %4, i32 %5, i32 0 |
| 35 | + ret i32 %6 |
| 36 | +} |
0 commit comments