2006-12-03 04:34:08 +08:00
|
|
|
; This test checks to make sure that constant exprs fold in some simple
|
|
|
|
; situations
|
2004-01-13 13:32:27 +08:00
|
|
|
|
2007-04-16 23:31:49 +08:00
|
|
|
; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | not grep {(}
|
2004-01-13 13:32:27 +08:00
|
|
|
|
|
|
|
%A = global long 0
|
|
|
|
|
|
|
|
global long* cast (long add (long cast (long* %A to long), long 0) to long*) ; X + 0 == X
|
|
|
|
global long* cast (long sub (long cast (long* %A to long), long 0) to long*) ; X - 0 == X
|
|
|
|
global long* cast (long mul (long cast (long* %A to long), long 0) to long*) ; X * 0 == 0
|
|
|
|
global long* cast (long div (long cast (long* %A to long), long 1) to long*) ; X / 1 == X
|
|
|
|
global long* cast (long rem (long cast (long* %A to long), long 1) to long*) ; X % 1 == 0
|
|
|
|
global long* cast (long and (long cast (long* %A to long), long 0) to long*) ; X & 0 == 0
|
|
|
|
global long* cast (long and (long cast (long* %A to long), long -1) to long*) ; X & -1 == X
|
|
|
|
global long or (long cast (long* %A to long), long -1) ; X | -1 == -1
|
|
|
|
global long* cast (long xor (long cast (long* %A to long), long 0) to long*) ; X ^ 0 == X
|
|
|
|
|
|
|
|
%Ty = type { int, int }
|
|
|
|
%B = external global %Ty
|
|
|
|
|
|
|
|
global bool setlt (long* %A, long* getelementptr (long* %A, long 1)) ; true
|
|
|
|
global bool setlt (long* %A, long* getelementptr (long* %A, long 0)) ; false
|
2006-11-23 23:14:52 +08:00
|
|
|
global bool setlt (int* getelementptr (%Ty* %B, long 0, uint 0),
|
|
|
|
int* getelementptr (%Ty* %B, long 0, uint 1)) ; true
|
2004-07-08 23:38:23 +08:00
|
|
|
;global bool setne (long* %A, long* cast (%Ty* %B to long*)) ; true
|
2004-01-13 13:32:27 +08:00
|
|
|
|
2006-01-05 15:46:46 +08:00
|
|
|
global bool seteq ({ short }* cast (int 1 to { short }*), { short }* null)
|
|
|
|
global bool setlt ({ short }* cast (int 1 to { short }*), { short }* cast (int 2 to { short }*))
|
|
|
|
|