2002-05-06 07:43:36 +02:00
|
|
|
; This test makes sure that these instructions are properly eliminated.
|
2009-10-26 00:47:55 +01:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2002-05-06 07:43:36 +02:00
|
|
|
|
2009-11-29 01:51:17 +01:00
|
|
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test1(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i32 %A, 0
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test1(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 %A
|
2002-05-06 07:43:36 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test2(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i32 %A, -1
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test2(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 -1
|
2002-05-06 07:43:36 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i8 @test2a(i8 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i8 %A, -1
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i8 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test2a(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i8 -1
|
2003-03-10 23:43:56 +01:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test3(i1 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i1 %A, false
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test3(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i1 %A
|
2002-05-06 07:43:36 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test4(i1 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i1 %A, true
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test4(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i1 true
|
2002-05-06 07:43:36 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test5(i1 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i1 %A, %A
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test5(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i1 %A
|
2002-05-06 07:51:26 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test6(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i32 %A, %A
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test6(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 %A
|
2002-05-06 07:51:26 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
; A | ~A == -1
|
|
|
|
define i32 @test7(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%NotA = xor i32 -1, %A
|
|
|
|
%B = or i32 %A, %NotA
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %B
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test7(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 -1
|
2003-02-18 20:28:47 +01:00
|
|
|
}
|
2003-03-10 19:24:04 +01:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i8 @test8(i8 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i8 %A, -2
|
|
|
|
%C = or i8 %B, 1
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i8 %C
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test8(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i8 -1
|
2003-03-10 23:43:56 +01:00
|
|
|
}
|
2003-03-11 00:52:54 +01:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
; Test that (A|c1)|(B|c2) == (A|B)|(c1|c2)
|
|
|
|
define i8 @test9(i8 %A, i8 %B) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%C = or i8 %A, 1
|
|
|
|
%D = or i8 %B, -2
|
|
|
|
%E = or i8 %C, %D
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i8 %E
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test9(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i8 -1
|
2003-03-11 01:10:59 +01:00
|
|
|
}
|
2003-06-04 06:37:46 +02:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i8 @test10(i8 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i8 %A, 1
|
|
|
|
%C = and i8 %B, -2
|
2008-03-01 10:15:35 +01:00
|
|
|
; (X & C1) | C2 --> (X | C2) & (C1|C2)
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i8 %C, -2
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i8 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test10(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i8 -2
|
2003-07-23 20:28:42 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i8 @test11(i8 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i8 %A, -2
|
|
|
|
%C = xor i8 %B, 13
|
2008-03-01 10:15:35 +01:00
|
|
|
; (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2)
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i8 %C, 1
|
|
|
|
%E = xor i8 %D, 12
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i8 %E
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test11(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i8 -1
|
2003-07-23 20:28:42 +02:00
|
|
|
}
|
2003-07-23 21:05:29 +02:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test12(i32 %A) {
|
|
|
|
; Should be eliminated
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i32 %A, 4
|
|
|
|
%C = and i32 %B, 8
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %C
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test12(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: %C = and i32 %A, 8
|
|
|
|
; CHECK: ret i32 %C
|
2003-07-23 21:05:29 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test13(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = or i32 %A, 12
|
2008-03-01 10:15:35 +01:00
|
|
|
; Always equal to 8
|
2009-10-26 00:47:55 +01:00
|
|
|
%C = and i32 %B, 8
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %C
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test13(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 8
|
2003-07-23 21:24:34 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test14(i32 %A, i32 %B) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%C1 = icmp ult i32 %A, %B
|
|
|
|
%C2 = icmp ugt i32 %A, %B
|
2008-03-01 10:15:35 +01:00
|
|
|
; (A < B) | (A > B) === A != B
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i1 %C1, %C2
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test14(
|
2010-03-05 09:43:33 +01:00
|
|
|
; CHECK: icmp ne i32 %A, %B
|
|
|
|
; CHECK: ret i1
|
2003-07-24 21:31:08 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test15(i32 %A, i32 %B) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%C1 = icmp ult i32 %A, %B
|
|
|
|
%C2 = icmp eq i32 %A, %B
|
2008-03-01 10:15:35 +01:00
|
|
|
; (A < B) | (A == B) === A <= B
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i1 %C1, %C2
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test15(
|
2010-03-05 09:43:33 +01:00
|
|
|
; CHECK: icmp ule i32 %A, %B
|
|
|
|
; CHECK: ret i1
|
2003-07-24 21:44:51 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test16(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = and i32 %A, 1
|
2008-03-01 10:15:35 +01:00
|
|
|
; -2 = ~1
|
2009-10-26 00:47:55 +01:00
|
|
|
%C = and i32 %A, -2
|
2008-03-01 10:15:35 +01:00
|
|
|
; %D = and int %B, -1 == %B
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i32 %B, %C
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test16(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 %A
|
2003-08-12 21:10:50 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test17(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = and i32 %A, 1
|
|
|
|
%C = and i32 %A, 4
|
2008-03-01 10:15:35 +01:00
|
|
|
; %D = and int %B, 5
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i32 %B, %C
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test17(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: %D = and i32 %A, 5
|
|
|
|
; CHECK: ret i32 %D
|
2003-08-12 21:10:50 +02:00
|
|
|
}
|
2004-09-29 00:31:49 +02:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test18(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = icmp sge i32 %A, 100
|
|
|
|
%C = icmp slt i32 %A, 50
|
2008-03-01 10:15:35 +01:00
|
|
|
;; (A-50) >u 50
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i1 %B, %C
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test18(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: add i32
|
2010-03-05 09:43:33 +01:00
|
|
|
; CHECK: icmp ugt
|
|
|
|
; CHECK: ret i1
|
2004-09-29 00:31:49 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i1 @test19(i32 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = icmp eq i32 %A, 50
|
|
|
|
%C = icmp eq i32 %A, 51
|
2013-04-14 23:15:43 +02:00
|
|
|
;; (A&-2) == 50
|
2009-10-26 00:47:55 +01:00
|
|
|
%D = or i1 %B, %C
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test19(
|
2013-04-14 23:15:43 +02:00
|
|
|
; CHECK: and i32
|
|
|
|
; CHECK: icmp eq
|
2010-03-05 09:43:33 +01:00
|
|
|
; CHECK: ret i1
|
2004-09-29 00:31:49 +02:00
|
|
|
}
|
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test20(i32 %x) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%y = and i32 %x, 123
|
|
|
|
%z = or i32 %y, %x
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %z
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test20(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 %x
|
2005-05-06 02:58:09 +02:00
|
|
|
}
|
2005-09-18 05:39:02 +02:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test21(i32 %tmp.1) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%tmp.1.mask1 = add i32 %tmp.1, 2
|
|
|
|
%tmp.3 = and i32 %tmp.1.mask1, -2
|
|
|
|
%tmp.5 = and i32 %tmp.1, 1
|
2008-03-01 10:15:35 +01:00
|
|
|
;; add tmp.1, 2
|
2009-10-26 00:47:55 +01:00
|
|
|
%tmp.6 = or i32 %tmp.5, %tmp.3
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %tmp.6
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test21(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: add i32 %{{[^,]*}}, 2
|
|
|
|
; CHECK: ret i32
|
2005-09-18 05:39:02 +02:00
|
|
|
}
|
2006-02-12 09:01:35 +01:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i32 @test22(i32 %B) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%ELIM41 = and i32 %B, 1
|
|
|
|
%ELIM7 = and i32 %B, -2
|
|
|
|
%ELIM5 = or i32 %ELIM41, %ELIM7
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i32 %ELIM5
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test22(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: ret i32 %B
|
2008-03-01 10:15:35 +01:00
|
|
|
}
|
2006-02-26 20:55:30 +01:00
|
|
|
|
2008-03-01 10:15:35 +01:00
|
|
|
define i16 @test23(i16 %A) {
|
2009-10-26 00:47:55 +01:00
|
|
|
%B = lshr i16 %A, 1
|
2008-03-01 10:15:35 +01:00
|
|
|
;; fold or into xor
|
2009-10-26 00:47:55 +01:00
|
|
|
%C = or i16 %B, -32768
|
|
|
|
%D = xor i16 %C, 8193
|
2008-03-01 10:15:35 +01:00
|
|
|
ret i16 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test23(
|
2009-10-26 00:47:55 +01:00
|
|
|
; CHECK: %B = lshr i16 %A, 1
|
|
|
|
; CHECK: %D = xor i16 %B, -24575
|
|
|
|
; CHECK: ret i16 %D
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR1738
|
|
|
|
define i1 @test24(double %X, double %Y) {
|
|
|
|
%tmp9 = fcmp uno double %X, 0.000000e+00 ; <i1> [#uses=1]
|
|
|
|
%tmp13 = fcmp uno double %Y, 0.000000e+00 ; <i1> [#uses=1]
|
|
|
|
%bothcond = or i1 %tmp13, %tmp9 ; <i1> [#uses=1]
|
|
|
|
ret i1 %bothcond
|
|
|
|
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test24(
|
2010-03-05 09:43:33 +01:00
|
|
|
; CHECK: = fcmp uno double %Y, %X
|
|
|
|
; CHECK: ret i1
|
2009-10-26 02:06:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
; PR3266 & PR5276
|
|
|
|
define i1 @test25(i32 %A, i32 %B) {
|
|
|
|
%C = icmp eq i32 %A, 0
|
|
|
|
%D = icmp eq i32 %B, 57
|
|
|
|
%E = or i1 %C, %D
|
|
|
|
%F = xor i1 %E, -1
|
|
|
|
ret i1 %F
|
|
|
|
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test25(
|
2009-10-26 02:06:31 +01:00
|
|
|
; CHECK: icmp ne i32 %A, 0
|
|
|
|
; CHECK-NEXT: icmp ne i32 %B, 57
|
|
|
|
; CHECK-NEXT: %F = and i1
|
|
|
|
; CHECK-NEXT: ret i1 %F
|
|
|
|
}
|
2009-11-29 01:51:17 +01:00
|
|
|
|
|
|
|
; PR5634
|
|
|
|
define i1 @test26(i32 %A, i32 %B) {
|
|
|
|
%C1 = icmp eq i32 %A, 0
|
|
|
|
%C2 = icmp eq i32 %B, 0
|
|
|
|
; (A == 0) & (A == 0) --> (A|B) == 0
|
|
|
|
%D = and i1 %C1, %C2
|
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test26(
|
2009-11-29 01:51:17 +01:00
|
|
|
; CHECK: or i32 %A, %B
|
|
|
|
; CHECK: icmp eq i32 {{.*}}, 0
|
|
|
|
; CHECK: ret i1
|
|
|
|
}
|
|
|
|
|
2010-01-02 16:25:44 +01:00
|
|
|
define i1 @test27(i32* %A, i32* %B) {
|
|
|
|
%C1 = ptrtoint i32* %A to i32
|
|
|
|
%C2 = ptrtoint i32* %B to i32
|
|
|
|
%D = or i32 %C1, %C2
|
|
|
|
%E = icmp eq i32 %D, 0
|
|
|
|
ret i1 %E
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test27(
|
2010-01-02 16:25:44 +01:00
|
|
|
; CHECK: icmp eq i32* %A, null
|
|
|
|
; CHECK: icmp eq i32* %B, null
|
|
|
|
; CHECK: and i1
|
|
|
|
; CHECK: ret i1
|
|
|
|
}
|
|
|
|
|
2009-11-29 01:51:17 +01:00
|
|
|
; PR5634
|
|
|
|
define i1 @test28(i32 %A, i32 %B) {
|
|
|
|
%C1 = icmp ne i32 %A, 0
|
|
|
|
%C2 = icmp ne i32 %B, 0
|
|
|
|
; (A != 0) | (A != 0) --> (A|B) != 0
|
|
|
|
%D = or i1 %C1, %C2
|
|
|
|
ret i1 %D
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test28(
|
2009-11-29 01:51:17 +01:00
|
|
|
; CHECK: or i32 %A, %B
|
|
|
|
; CHECK: icmp ne i32 {{.*}}, 0
|
|
|
|
; CHECK: ret i1
|
|
|
|
}
|
2010-01-02 17:14:56 +01:00
|
|
|
|
|
|
|
define i1 @test29(i32* %A, i32* %B) {
|
|
|
|
%C1 = ptrtoint i32* %A to i32
|
|
|
|
%C2 = ptrtoint i32* %B to i32
|
|
|
|
%D = or i32 %C1, %C2
|
|
|
|
%E = icmp ne i32 %D, 0
|
|
|
|
ret i1 %E
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test29(
|
2010-01-02 17:14:56 +01:00
|
|
|
; CHECK: icmp ne i32* %A, null
|
|
|
|
; CHECK: icmp ne i32* %B, null
|
|
|
|
; CHECK: or i1
|
|
|
|
; CHECK: ret i1
|
|
|
|
}
|
|
|
|
|
2010-01-04 07:03:59 +01:00
|
|
|
; PR4216
|
|
|
|
define i32 @test30(i32 %A) {
|
|
|
|
entry:
|
|
|
|
%B = or i32 %A, 32962
|
|
|
|
%C = and i32 %A, -65536
|
|
|
|
%D = and i32 %B, 40186
|
|
|
|
%E = or i32 %D, %C
|
|
|
|
ret i32 %E
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test30(
|
2010-09-13 19:59:27 +02:00
|
|
|
; CHECK: %D = and i32 %A, -58312
|
|
|
|
; CHECK: %E = or i32 %D, 32962
|
2010-01-04 07:03:59 +01:00
|
|
|
; CHECK: ret i32 %E
|
|
|
|
}
|
add one more bitfield optimization, allowing clang to generate
good code on PR4216:
_test_bitfield: ## @test_bitfield
orl $32962, %edi
movl $4294941946, %eax
andq %rdi, %rax
ret
instead of:
_test_bitfield:
movl $4294941696, %ecx
movl %edi, %eax
orl $194, %edi
orl $32768, %eax
andq $250, %rdi
andq %rax, %rcx
movq %rdi, %rax
orq %rcx, %rax
ret
Evan is looking into the remaining andq+imm -> andl optimization.
llvm-svn: 93147
2010-01-11 07:55:24 +01:00
|
|
|
|
|
|
|
; PR4216
|
|
|
|
define i64 @test31(i64 %A) nounwind readnone ssp noredzone {
|
|
|
|
%B = or i64 %A, 194
|
|
|
|
%D = and i64 %B, 250
|
|
|
|
|
|
|
|
%C = or i64 %A, 32768
|
|
|
|
%E = and i64 %C, 4294941696
|
|
|
|
|
|
|
|
%F = or i64 %D, %E
|
|
|
|
ret i64 %F
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test31(
|
2011-05-19 01:58:37 +02:00
|
|
|
; CHECK-NEXT: %E = and i64 %A, 4294908984
|
|
|
|
; CHECK-NEXT: %F = or i64 %E, 32962
|
add one more bitfield optimization, allowing clang to generate
good code on PR4216:
_test_bitfield: ## @test_bitfield
orl $32962, %edi
movl $4294941946, %eax
andq %rdi, %rax
ret
instead of:
_test_bitfield:
movl $4294941696, %ecx
movl %edi, %eax
orl $194, %edi
orl $32768, %eax
andq $250, %rdi
andq %rax, %rcx
movq %rdi, %rax
orq %rcx, %rax
ret
Evan is looking into the remaining andq+imm -> andl optimization.
llvm-svn: 93147
2010-01-11 07:55:24 +01:00
|
|
|
; CHECK-NEXT: ret i64 %F
|
|
|
|
}
|
2010-02-02 03:43:51 +01:00
|
|
|
|
|
|
|
define <4 x i32> @test32(<4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32> %vecinit6.i191) {
|
|
|
|
%and.i135 = sext <4 x i1> %and.i1352 to <4 x i32> ; <<4 x i32>> [#uses=2]
|
|
|
|
%and.i129 = and <4 x i32> %vecinit6.i176, %and.i135 ; <<4 x i32>> [#uses=1]
|
|
|
|
%neg.i = xor <4 x i32> %and.i135, <i32 -1, i32 -1, i32 -1, i32 -1> ; <<4 x i32>> [#uses=1]
|
|
|
|
%and.i = and <4 x i32> %vecinit6.i191, %neg.i ; <<4 x i32>> [#uses=1]
|
|
|
|
%or.i = or <4 x i32> %and.i, %and.i129 ; <<4 x i32>> [#uses=1]
|
|
|
|
ret <4 x i32> %or.i
|
2013-02-17 00:41:36 +01:00
|
|
|
; codegen is mature enough to handle vector selects.
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test32(
|
2013-02-17 00:41:36 +01:00
|
|
|
; CHECK: select <4 x i1> %and.i1352, <4 x i32> %vecinit6.i176, <4 x i32> %vecinit6.i191
|
2010-02-02 03:43:51 +01:00
|
|
|
}
|
|
|
|
|
2010-09-11 00:39:55 +02:00
|
|
|
define i1 @test33(i1 %X, i1 %Y) {
|
|
|
|
%a = or i1 %X, %Y
|
|
|
|
%b = or i1 %a, %X
|
|
|
|
ret i1 %b
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test33(
|
2010-09-11 00:39:55 +02:00
|
|
|
; CHECK-NEXT: or i1 %X, %Y
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test34(i32 %X, i32 %Y) {
|
|
|
|
%a = or i32 %X, %Y
|
|
|
|
%b = or i32 %Y, %a
|
|
|
|
ret i32 %b
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test34(
|
2010-09-11 00:39:55 +02:00
|
|
|
; CHECK-NEXT: or i32 %X, %Y
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
}
|
2010-09-13 19:59:27 +02:00
|
|
|
|
|
|
|
define i32 @test35(i32 %a, i32 %b) {
|
|
|
|
%1 = or i32 %a, 1135
|
|
|
|
%2 = or i32 %1, %b
|
|
|
|
ret i32 %2
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test35(
|
2010-09-13 19:59:27 +02:00
|
|
|
; CHECK-NEXT: or i32 %a, %b
|
|
|
|
; CHECK-NEXT: or i32 %1, 1135
|
|
|
|
}
|
2010-12-20 17:18:51 +01:00
|
|
|
|
|
|
|
define i1 @test36(i32 %x) {
|
|
|
|
%cmp1 = icmp eq i32 %x, 23
|
|
|
|
%cmp2 = icmp eq i32 %x, 24
|
|
|
|
%ret1 = or i1 %cmp1, %cmp2
|
|
|
|
%cmp3 = icmp eq i32 %x, 25
|
|
|
|
%ret2 = or i1 %ret1, %cmp3
|
|
|
|
ret i1 %ret2
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test36(
|
2010-12-20 17:18:51 +01:00
|
|
|
; CHECK-NEXT: %x.off = add i32 %x, -23
|
|
|
|
; CHECK-NEXT: icmp ult i32 %x.off, 3
|
|
|
|
; CHECK-NEXT: ret i1
|
|
|
|
}
|
|
|
|
|
2011-04-15 00:41:27 +02:00
|
|
|
define i32 @test37(i32* %xp, i32 %y) {
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test37(
|
2011-04-15 00:41:27 +02:00
|
|
|
; CHECK: select i1 %tobool, i32 -1, i32 %x
|
|
|
|
%tobool = icmp ne i32 %y, 0
|
|
|
|
%sext = sext i1 %tobool to i32
|
|
|
|
%x = load i32* %xp
|
|
|
|
%or = or i32 %sext, %x
|
|
|
|
ret i32 %or
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test38(i32* %xp, i32 %y) {
|
2013-07-14 03:42:54 +02:00
|
|
|
; CHECK-LABEL: @test38(
|
2011-04-15 00:41:27 +02:00
|
|
|
; CHECK: select i1 %tobool, i32 -1, i32 %x
|
|
|
|
%tobool = icmp ne i32 %y, 0
|
|
|
|
%sext = sext i1 %tobool to i32
|
|
|
|
%x = load i32* %xp
|
|
|
|
%or = or i32 %x, %sext
|
|
|
|
ret i32 %or
|
|
|
|
}
|