aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstCombine/2012-07-11-AddSubDemandedBits.ll
blob: d62a8864d71856b253255c6d91d30b04aa864e50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
; RUN: opt < %s -instcombine -S | FileCheck %s

; When shrinking demanded constant operand of an add instruction, keep in
; mind the opcode can be changed to sub and the constant negated. Make sure
; the shrinking the constant would actually reduce the width.
; rdar://11793464

define i64 @t(i64 %key, i64* %val) nounwind {
entry:
; CHECK: @t
; CHECK-NOT: add i64 %0, 2305843009213693951
; CHECK: add i64 %0, -1
  %shr = lshr i64 %key, 3
  %0 = load i64* %val, align 8
  %sub = sub i64 %0, 1
  %and = and i64 %sub, %shr
  ret i64 %and
}