2016-03-26 04:12:25 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by update_test_checks.py
|
2015-09-09 02:36:56 +08:00
|
|
|
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
2014-06-19 11:51:46 +08:00
|
|
|
|
|
|
|
; Test the case where integer BitWidth <= 64 && BitWidth % 2 != 0.
|
|
|
|
define i39 @test1(i39 %V, i39 %M) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
|
|
|
; CHECK: [[N:%.*]] = and i39 %M, -274877906944
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = add i39 %V, [[N]]
|
|
|
|
; CHECK-NEXT: ret i39 [[A]]
|
|
|
|
;
|
2014-06-19 11:51:46 +08:00
|
|
|
;; If we have: ((V + N) & C1) | (V & C2)
|
|
|
|
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
|
|
|
|
;; replace with V+N.
|
|
|
|
%C1 = xor i39 274877906943, -1 ;; C2 = 274877906943
|
|
|
|
%N = and i39 %M, 274877906944
|
|
|
|
%A = add i39 %V, %N
|
|
|
|
%B = and i39 %A, %C1
|
|
|
|
%D = and i39 %V, 274877906943
|
|
|
|
%R = or i39 %B, %D
|
|
|
|
ret i39 %R
|
|
|
|
}
|
|
|
|
|
2015-09-09 02:36:56 +08:00
|
|
|
define i7 @test2(i7 %X) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
|
|
|
; CHECK: ret i7 %X
|
|
|
|
;
|
2015-09-09 02:36:56 +08:00
|
|
|
%Y = or i7 %X, 0
|
|
|
|
ret i7 %Y
|
|
|
|
}
|
|
|
|
|
|
|
|
define i17 @test3(i17 %X) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
|
|
|
; CHECK: ret i17 -1
|
|
|
|
;
|
2015-09-09 02:36:56 +08:00
|
|
|
%Y = or i17 %X, -1
|
|
|
|
ret i17 %Y
|
|
|
|
}
|
|
|
|
|
2016-03-26 04:12:25 +08:00
|
|
|
; Test the case where Integer BitWidth > 64 && BitWidth <= 1024.
|
2015-09-09 02:36:56 +08:00
|
|
|
define i399 @test4(i399 %V, i399 %M) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
|
|
|
; CHECK: [[N:%.*]] = and i399 %M, 18446742974197923840
|
|
|
|
; CHECK-NEXT: [[A:%.*]] = add i399 %V, [[N]]
|
|
|
|
; CHECK-NEXT: ret i399 [[A]]
|
|
|
|
;
|
2014-06-19 11:51:46 +08:00
|
|
|
;; If we have: ((V + N) & C1) | (V & C2)
|
|
|
|
;; .. and C2 = ~C1 and C2 is 0+1+ and (N & C2) == 0
|
|
|
|
;; replace with V+N.
|
|
|
|
%C1 = xor i399 274877906943, -1 ;; C2 = 274877906943
|
|
|
|
%N = and i399 %M, 18446742974197923840
|
|
|
|
%A = add i399 %V, %N
|
|
|
|
%B = and i399 %A, %C1
|
|
|
|
%D = and i399 %V, 274877906943
|
|
|
|
%R = or i399 %B, %D
|
|
|
|
ret i399 %R
|
|
|
|
}
|
2015-09-09 02:36:56 +08:00
|
|
|
|
|
|
|
define i777 @test5(i777 %X) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
|
|
|
; CHECK: ret i777 %X
|
|
|
|
;
|
2015-09-09 02:36:56 +08:00
|
|
|
%Y = or i777 %X, 0
|
|
|
|
ret i777 %Y
|
|
|
|
}
|
|
|
|
|
|
|
|
define i117 @test6(i117 %X) {
|
2016-03-26 04:12:25 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
|
|
|
; CHECK: ret i117 -1
|
|
|
|
;
|
2015-09-09 02:36:56 +08:00
|
|
|
%Y = or i117 %X, -1
|
|
|
|
ret i117 %Y
|
|
|
|
}
|