| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt -passes='default<O3>' -S < %s | FileCheck %s | |
| target datalayout = "e-p:64:64" | |
| ; Commoning the null comparisons exposed by the pointer umax decomposition | |
| ; allows (X == null) || ((X == null) && (Y == null)) to simplify to X == null. | |
| define i1 @umax_null_logical_or(ptr %x, ptr %y) { | |
| ; CHECK-LABEL: @umax_null_logical_or( | |
| ; CHECK-NEXT: [[XNULL:%.*]] = icmp eq ptr [[X:%.*]], null | |
| ; CHECK-NEXT: ret i1 [[XNULL]] | |
| ; | |
| %xnull = icmp eq ptr %x, null | |
| %cmp = icmp ugt ptr %x, %y | |
| %max = select i1 %cmp, ptr %x, ptr %y | |
| %maxnull = icmp eq ptr %max, null | |
| %r = select i1 %xnull, i1 true, i1 %maxnull | |
| ret i1 %r | |
| } | |
| ; The order of the comparisons exposed by the decomposition does not matter. | |
| define i1 @umax_null_logical_or_commuted(ptr %x, ptr %y) { | |
| ; CHECK-LABEL: @umax_null_logical_or_commuted( | |
| ; CHECK-NEXT: [[XNULL:%.*]] = icmp eq ptr [[X:%.*]], null | |
| ; CHECK-NEXT: ret i1 [[XNULL]] | |
| ; | |
| %xnull = icmp eq ptr %x, null | |
| %cmp = icmp ult ptr %y, %x | |
| %max = select i1 %cmp, ptr %x, ptr %y | |
| %maxnull = icmp eq ptr %max, null | |
| %r = select i1 %xnull, i1 true, i1 %maxnull | |
| ret i1 %r | |
| } |