File: pr87042.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (42 lines) | stat: -rw-r--r-- 1,645 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

; %or2 cannot be folded into %or1 because %or1 has disjoint.
; TODO: Can we move the logic into InstCombine and drop the disjoint flag?
define i64 @test(i1 %cond, i64 %x) {
; CHECK-LABEL: define i64 @test(
; CHECK-SAME: i1 [[COND:%.*]], i64 [[X:%.*]]) {
; CHECK-NEXT:    [[OR1:%.*]] = or disjoint i64 [[X]], 7
; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[COND]], i64 [[OR1]], i64 [[X]]
; CHECK-NEXT:    [[OR2:%.*]] = or i64 [[SEL1]], 7
; CHECK-NEXT:    ret i64 [[OR2]]
;
  %or1 = or disjoint i64 %x, 7
  %sel1 = select i1 %cond, i64 %or1, i64 %x
  %or2 = or i64 %sel1, 7
  ret i64 %or2
}

define i64 @pr87042(i64 %x) {
; CHECK-LABEL: define i64 @pr87042(
; CHECK-SAME: i64 [[X:%.*]]) {
; CHECK-NEXT:    [[AND1:%.*]] = and i64 [[X]], 65535
; CHECK-NEXT:    [[CMP1:%.*]] = icmp eq i64 [[AND1]], 0
; CHECK-NEXT:    [[OR1:%.*]] = or disjoint i64 [[X]], 7
; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[CMP1]], i64 [[OR1]], i64 [[X]]
; CHECK-NEXT:    [[AND2:%.*]] = and i64 [[SEL1]], 16776960
; CHECK-NEXT:    [[CMP2:%.*]] = icmp eq i64 [[AND2]], 0
; CHECK-NEXT:    [[OR2:%.*]] = or i64 [[SEL1]], 7
; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[CMP2]], i64 [[OR2]], i64 [[SEL1]]
; CHECK-NEXT:    ret i64 [[SEL2]]
;
  %and1 = and i64 %x, 65535
  %cmp1 = icmp eq i64 %and1, 0
  %or1 = or disjoint i64 %x, 7
  %sel1 = select i1 %cmp1, i64 %or1, i64 %x
  %and2 = and i64 %sel1, 16776960
  %cmp2 = icmp eq i64 %and2, 0
  %or2 = or i64 %sel1, 7
  %sel2 = select i1 %cmp2, i64 %or2, i64 %sel1
  ret i64 %sel2
}